When to Use the SSH Command in Linux

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

Linux SSH Command
Jupiterimages/Stockbyte/Getty Images

 

The Linux ssh command allows you to log in and work on a remote computer, which can be located anywhere in the world, using a secure encrypted connection between the two hosts over an insecure network. The command (syntax: ssh hostname) opens a window on your local machine through which you can run and interact with programs on the remote machine just as if it were right in front of you. You can use the remote computer's software, access its files, transfer files, and more.

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

Usage Examples

To log in to a computer with the network id comp.org.net and username jdoe, you'd 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

You'll then get a message something like this:

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.

Was this page helpful?