Networking

Linux ssh command

Connect securely to a remote machine using its account and host name.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

ssh [OPTION]... [USER@]HOST [COMMAND]

Examples

Open a remote shell as alice.

ssh alice@example.com

Connect on a custom port using a selected key.

ssh -p 2222 -i ~/.ssh/id_ed25519 alice@example.com

Parameters, options and clauses

Option / clauseDescription
-p PORTConnect to PORT on the remote host.
-i IDENTITY_FILEUse the specified private key file.
-J DESTConnect through a jump host.
-L [BIND:]PORT:HOST:HOSTPORTForward a local port to a remote destination.
-NDo not run a remote command; useful for forwarding only.
-vShow verbose connection diagnostics; repeat for more detail.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory