Use the SSH Command in Linux

Log in and work on any Linux computer anywhere in the world

Woman working on computer in park

Sigrid Olsson / Getty Images

The Linux ssh command accesses a remote computer using a secure encrypted connection between the two hosts over an insecure network. The command opens a window on your local machine, through which you can run and interact with programs on the remote machine.

An ssh Linux session is encrypted and requires authentication. Ssh stands for Secure SHell, referring to the operation's inherent security.

Usage Examples

These examples assume you're using SSH with a remote computer that accepts passwords. Read more about SSH key authentication for a more secure method of using SSH that does not require passwords.

To log in to a computer with the network id comp.org.net and username jdoe, use the following command:

ssh jdoe@comp.org.net

If the username of the remote machine is the same as on the local machine, you can omit the username in the command:

ssh comp.org.net

If it's your first login attempt on that machine, you'll encounter a one-time fingerprint alert:

The authenticity of host 'sample.ssh.com' cannot be established. DSA key fingerprint is 04:48:30:31:b0:f3:5a:9b:01:9d:b3:a7:38:e2:b1:0c. Are you sure you want to continue connecting (yes/no)?

Entering yes tells the machine to add the remote computer to your list of known hosts, ~/.ssh/known_hosts. You'll see a message such as this:

Warning: Permanently added 'sample.ssh.com' (DSA) to the list of known hosts.

Once you're connected, you'll be prompted for a password. After you enter it, you'll get the shell prompt for the remote machine.

You also can use an ssh command to run a command on a remote machine without logging in. For example:

ssh jdoe@comp.org.net ps

will execute the command ps on the computer comp.org.net and show the results in your local window.

Why Use SSH?

SSH is more secure than other methods of establishing a connection with a remote computer because you send your login credentials and password only after a secure channel has been established. Also, SSH supports public-key cryptography.