When to Use the SSH Command in Linux

Businessman at computer
Jupiterimages/Stockbyte/Getty Images

Linux's ssh command allows you to log into and work on a remote computer, which can be located anywhere in the world. 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 session is encrypted and requires authentication.​ Ssh stands for Secure SHell, referring to the operation's inherent security.

Usage Examples

To log into 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 ssh 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.

Was this page helpful?