One of the most important ways of using Linux is via SSH. This remote access command line tool lets you do everything from installing software to configuring Linux as a web server. SSH can save time, make you more productive, and help you unlock the power of your Linux distro.

But how do you set up SSH, on both the client and server sides? Learn how to install and configure SSH software at both ends and remotely control your Linux computer.

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.

Note that other remote access solutions are available for Linux. For example, Ubuntu users can rely on the VNC-compatible remote desktop tool Remmina.

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 a 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

Connect to a device using SSH in Windows PowerShell

  • To connect to Linux over SSH from iPhone and iPad try iTerminal ($4.99)
  • If you're using Android for SSH, try JuiceSSH (Free)

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 host name, 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 illicit a response of "active."

Check the status to confirm SSH is set up correctly

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 a 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 operating system or device name. This should make it simple to identify.

To display the public IP address, login 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 username@REMOTE.IP.ADDRESS.HERE
    

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?

Configure SSH on Windows with 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.

Can't Connect? Troubleshoot Your SSH Set Up

If you are having SSH connection issues, these are the possible causes:

  • SSH software isn't installed on either computer
  • Your username or password is incorrect
  • The IP address is wrong
  • A firewall is blocking the connection, or port 22 is not being forwarded

Double-check each point and you should be able to connect. If not, the problem might be more complex.

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

Setup SSH on a Linux server to run commands remotely

Check our list of SSH commands for managing a Linux server for more.

Setup SSH and Make Linux More Powerful

With SSH, Linux becomes considerably more flexible and powerful. You can literally remotely access a computer using a smartphone thanks to SSH.

If SSH is set up correctly, with client and server-side software enabled and configured, remote command line access is possible. Need something more? Here's how to remotely control a Linux desktop from Windows.