man.lsPlain-English help for Unix commands

ssh Log in to or run commands on a remote machine

Opens an encrypted connection to another computer and gives you a shell there, or runs a single command and returns. It is the standard way to administer servers. It can also forward network ports through the connection.

Synopsis

ssh [OPTION]... [user@]host [command]

Common options

Option or formWhat it does
-i FILEUse FILE as the private key (identity file) to log in
-p PORTConnect to PORT instead of the default 22. Lowercase p for ssh, capital P for scp
-L [bind:]port:host:hostportLocal port forwarding: connections to port on your machine are sent through the tunnel to host:hostport
-NDo not run a remote command. Useful with -L when you only want the tunnel
-vVerbose mode. Prints debugging messages. Add more v's for more detail
-J HOSTJump through HOST (a bastion or jump server) to reach the destination
-o OPTIONSet a config option on the command line, for example -o ServerAliveInterval=30
-fGo to the background just before running the command. Often combined with -N and -L

Examples

Log in to a server
ssh user@host
Log in with a specific key on a non-standard port
ssh -i ~/.ssh/id_ed25519 -p 2222 user@host
Run one command and come back
ssh user@host 'df -h'
Forward a local port to a database on the remote side
ssh -L 5433:localhost:5432 user@host
Tunnel only, in the background, with no shell
ssh -N -f -L 8080:localhost:80 user@host
Reach a private server through a jump host
ssh -J [email protected] [email protected]

Notes

See also

Last reviewed 2026-10-07.