Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.
Once you start getting more comfortable with using Linux, you’ll want to start making use of some great utilities that can make you vastly more productive. Arguably one of the most important utilities to learn is SSH. With it, you can control a different machine as if you were sitting directly at it. This can allow you to set up headless machines such as with a Raspberry Pi.
How do you set it up, on both the client and server sides? We’ll take you through a basic installation so that you can connect between the two.
Simply put, SSH (Secure Shell) allows you to connect to a different computer and gain terminal access to it despite not physically sitting right in front of it. SSH doesn’t give you access to the graphical desktop environment (normally, at least), but it will give you terminal access. That alone is a good enough reason to brush up on your terminal skills. Once you’re connected to the other computer, you can do virtually whatever you want, especially if you have root access on the remote user account.
Getting SSH installed is really easy, and only takes a few other bits of information to get going. On the computer which you’d like to use to connect to other computers, you’ll need to install the OpenSSH client if it isn’t already. On Ubuntu systems this can be done with
sudo apt-get install openssh-client. Once that installation completes, you’re already good to go with one computer.
Alternatively, you could also install PuTTY if you are used to it or other SSH clients on Windows, even though I personally still prefer using the terminal directly instead of PuTTY. However, for those you want it, they can install it with the command
sudo apt-get install putty.
On every computer that you want to connect to, you’ll need to install the server-side part of the software if it isn’t already. You can do so on Ubuntu systems with the command
sudo apt-get install openssh-server. Once this is installed, all of the needed software is installed.
Determine IP Address
Now, you need to know the IP address (or web address) that you can use to get to the computer you want to connect to. If the computer is connected to the same network as yours, it’d be best to use the local IP address (i.e. 192.168.1.2) rather than the public IP address (i.e. 100.101.102.103).
Otherwise, if the computer is located on a different network, you’ll need to use the public IP address and make sure that port 22 is forwarded to the computer in question, if possible and needed.
If you need to know the local IP address, you can run the command
ifconfig and then see what IP address it gives you. For the public IP address, you can visit a site like whatsmyip.org and have it tell you.
Connecting via SSH
Once you have the IP address you need to use, make sure you also have a username and password that works on the machine you’re connecting to, and then run the command
ssh email@example.com, replacing username with the actual username and 22.214.171.124 with the actual IP address you need to use. Hit Enter, and it will ask you for the user’s password. With a correct password, you’ll get a functioning terminal prompt — you’re now logged into the remote computer!
If you are having any issues, these are the possible issues:
- Software isn’t installed on either computer
- Username/password is wrong
- IP address is wrong
- A firewall somewhere along the way is blocking or not forwarding port 22
Double-check all of these points and you should be able to connect. If not, you might have a complex problem on your hands.
What Do You Use SSH For?
SSH can become a really useful tool if you have to manage multiple Linux computers — you can work on all of them from just one system. Even if you don’t have any serious work that SSH can help with, it’s a quick and easy little experiment you can try out for yourself. I always find it a little awesome whenever I send a shutdown command to a remote computer and then see the computer shutting down without me physically touching it.
What great uses have you found for SSH? What advanced things can you suggest people do with SSH? Let us know in the comments!