What Is SSH?
SSH stands for Secure Shell and allows you to remotely control a Linux computer or server from another device. It works across local area networks and the internet, meaning that it can be used to manage a Linux-powered media server in your house, or a Linux web server on a different continent.
While SSH doesn’t give you access to the remote computer’s desktop environment, it lets you use the terminal. Once connected to the remote computer you can use it as if it was right in front of you. Just be sure to have root access.
To use SSH, you’ll need to ensure that the remote computer (server) has SSH set up. Additionally, your local device (the client) will need an SSH app installing.
Client-Side Installation
Installing and setting up SSH on a client is simple. In some cases you don’t even need any additional software:
- Linux users should find an SSH client built into the terminal
- macOS computers also have SSH preinstalled in the terminal
- Windows PCs will need to use the PowerShell command-line tool, or install PuTTY
- To connect to Linux over SSH from iPhone and iPad try iTerminal
- If you’re using Android for SSH, try JuiceSSH
SSH not installed on your Linux system? Add by updating packages and upgrading, then installing:
sudo apt update && sudo apt upgrade sudo apt install openssh-client
Used to using SSH on Windows but have switched to a Linux desktop? You might miss the PuTTY desktop SSH app with its easy mouse interface. Fortunately, it can be installed on a Linux desktop:
sudo apt install putty
With your SSH client software installed, you’re ready to set up a connection to your remote computer or server.
As a general rule for all desktop and mobile clients, all you need is an IP address or hostname, and appropriate login details. While the look of the apps may differ, and the port name may need entering manually, SSH clients are mostly indistinguishable.
Server-Side Installation and Configuration
Before establishing a connection, install the server-side software to host your SSH connection. This requires someone to be present to install or enable SSH. You might already be present to do this otherwise, a colleague or support engineer at the server end will set up SSH.
Note that if you’re using a web hosting package, SSH should be enabled by default. Speak to your web host to set up SSH if not.
If SSH is not enabled on the remote computer or server, install it with
sudo apt install openssh-server
Check this worked with
sudo systemctl status ssh
The command should elicit a response of “active.”
In some cases the Ubuntu firewall ufw may block SSH. To ensure this doesn’t happen, use
sudo ufw allow ssh
In some cases you’ll need to also enable SSH on the remote device. This is a security precaution that can be tweaked using
sudo systemctl enable ssh
Other options are available (stop
, start
, and disable
) for configuring the SSH service.
Determine IP Address
To connect to the remote device over SSH, you’ll need to know the IP address of the machine. You have two easy ways to find this:
- Run a terminal command
- Check the router
To display the IP address of the remote system, logon and run
ip address
This will return the device’s IP address, so take note of it. On older Linux versions ifconfig
may provide better results.
You can also check your router to see connected devices. The Linux PC or server will be listed, typically by the operating system or device name. This should make it simple to identify.
To display the public IP address, log in to the server, and open whatsmyip.org.
The IP address you use should be the one suitable for the connection. So, if the device is on the same network as the client, use the local IP address. For connections across the internet, use the public IP address. If the computer is located on a different network, make sure that port 22 is forwarded to the computer.
Connecting to Linux via SSH
Along with the correct IP address you should also have a username and password to gain access to the remote machine.
For command-line SSH tools, use
ssh [email protected]
Be sure to replace username with the actual username and REMOTE.IP.ADDRESS.HERE with the remote device’s IP address. Hit Enter, and you’ll be prompted for the password.
With a correct password, you’ll get a functioning terminal prompt you’re now logged into the remote computer.
Using a desktop SSH client like PuTTY?
Input the Host Name or IP address, select the SSH connection type, then Open. When prompted for your username and password, enter them in the command line window to complete the connection and gain remote access.
Using Linux Remotely With SSH
SSH is a useful tool for managing one or more Linux computers.
It lets you can work on any machine from just one system. You can input almost any Linux terminal command over SSH.
Key examples include:
- Update: sudo apt update && sudo apt upgrade
- Check status: uptime
- Running processes: ps
- Running processes by CPU: top