How to enable SSH on Ubuntu 20.04

s2 0

Secure Shell (SSH) is a network protocol used for a secure connection between a client and a server. Every interaction between the server and a client is encrypted.

This tutorial is going to explain how to enable SSH on an Ubuntu computer.

If you enable SSH, you can remotely connect to your system and perform administrative tasks. You can also securely store files via. transfer scp
and sftp

Enabling SSH on Ubuntu

By default, remote access via SSH is not allowed when you first install Ubuntu. Enabling SSH on Ubuntu is pretty straightforward.

Perform the following steps as root or user with sudo privileges to install and enable SSH on your Ubuntu system:

  1. Open the terminal with Ctrl+Alt+T and install the openssh-server Package:

    sudo apt updatesudo apt install openssh-server

    When prompted, enter your password and press Enter to proceed with the installation.

  2. Once the installation is complete, the SSH service will start automatically. You can check if SSH is running by typing:

    sudo systemctl status ssh

    The output should tell you that the service is running and enabled to start at system startup:

    ‚óŹ ssh.service - OpenBSD Secure Shell server
        Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
        Active: active (running) since Mon 2020-06-01 12:34:00 CEST; 9h ago

    Press q to return to the command line prompt.

  3. Ubuntu comes with a firewall configuration tool called UFW. If the firewall is enabled on your system, make sure you open the SSH port:

    sudo ufw allow ssh

That’s it! You can now connect to your Ubuntu system from any remote computer using SSH. SSH clients are installed by default on Linux and macOS systems. To connect from a Windows computer, use an SSH client such as putty

Establish a connection to the SSH server

To establish a connection to your Ubuntu computer via LAN, call the ssh command followed by the user name and the IP address in the following format:

ssh [email protected]_address
Make sure you change yourself username with the actual username and ip_address with the IP address of the Ubuntu computer on which you installed SSH.

If you don’t know your IP address, you can easily get it from the ip Command:

ip a

As you can see from the output, the system IP address is

Once you find the IP address, log into the remote computer by doing the following: ssh

ssh [email protected]

The first time you connect, you’ll see a message like this:

The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:Vybt22mVXuNuB5unE++yowF7lgA/9/2bLSiO3qmYWBY.
Are you sure you want to continue connecting (yes/no)?

Type yes and you will be asked to enter your password.

Warning: Permanently added '' (ECDSA) to the list of known hosts.
[email protected]'s password:

Once you enter the password, you will be greeted with the standard Ubuntu message:

Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-26-generic x86_64)

 * Documentation:
 * Management:
 * Support:

You are now logged into your Ubuntu computer.

Connection to SSH behind NAT. produce

To connect to your Ubuntu home computer over the internet, you’ll need to know your public IP address and configure your router to accept data on port 22 and send it to the Ubuntu system that is running SSH.

To find out the public IP address of the computer you want to SSH connection to, simply go to the following url:


When it comes to setting up port forwarding, each router has a different way of setting up port forwarding. Consult your router’s documentation for information on setting up port forwarding. In short, you need to enter the port number that requests will be made to (default SSH port is 22) and the private IP address you found earlier (using the ip a Command) of the computer running SSH.

Once you’ve found the IP address and configured your router, you can log in by typing:

ssh [email protected]_ip_address

When exposing your computer to the Internet, there are a few security measures that you should take. The easiest way is to configure your router to accept SSH traffic on a non-standard port and forward it to port 22 on the computer running the SSH service.

You can also set up SSH key-based authentication and connect to your Ubuntu computer without entering a password.

Disabling SSH on Ubuntu

To disable the SSH server on your Ubuntu system, simply stop the SSH service by running:

sudo systemctl disable --now ssh

To turn it back on later, type:

sudo systemctl enable --now ssh


We showed you how to install and activate SSH on your Ubuntu 20.04. You can now log in to your computer and perform day-to-day system administration tasks from the command prompt.

If you manage multiple systems, you can simplify your workflow by defining all of your connections in the SSH configuration file. Changing the default SSH port adds an extra layer of security to your system by reducing the risk of automated attacks.

For more information on configuring your SSH server, see the Ubuntu SSH / OpenSSH / Configure
Instructions and the official SSH manual

If you have any questions please leave a comment below.