Linux Command: ssh
Securely connect to remote servers
SSH (Secure Shell) provides encrypted remote login and command execution over insecure networks. It is the primary method for securely accessing remote Linux servers, replacing older unencrypted protocols like telnet and rsh. ssh supports password authentication, public key authentication, X11 forwarding, port forwarding (tunneling), SOCKS proxying, and agent forwarding. Public key authentication is strongly recommended for security and convenience. SSH is fundamental to system administration, remote development, deployment automation, and secure data transfer. Tools like scp, sftp, rsync, and git all use SSH for secure transport.
Syntax
ssh [OPTION]... [USER@]HOSTNAME [COMMAND]Common Examples
ssh user@192.168.1.100— Opens an interactive shell on the remote server.ssh user@server "df -h && free -m"— Executes commands on the remote server and returns output locally.ssh -i ~/.ssh/mykey.pem ubuntu@ec2-instance.aws.com— Connects using a specific SSH private key file.ssh -L 3306:localhost:3306 user@db-server -N— Forwards local port 3306 to the database server — access remote MySQL locally.
Pro Tips
Master this and 230+ other Linux commands with our comprehensive eBooks and cheat sheets.
Related Resources