Sep 5, 2023 5 min read

How to Install and Enable SSH on Ubuntu 20.04

Install and Enable SSH on Ubuntu 20.04 with our step-by-step tutorial. It allows remote access and secure communication between two devices.

Install and Enable SSH on Ubuntu 20.04
Table of Contents

Choose a different version or distribution


Before we begin talking about how to enable SSH on Ubuntu 20.04, let’s briefly understand - What is SSH?

SSH (Secure Shell) is a secure network protocol that allows remote access and secure communication between two devices. It provides a secure way to connect to and manage remote servers and computers over an unsecured network, like the internet. SSH encrypts the data sent between devices, ensuring confidentiality and protecting against unauthorized access.

It is widely used by system administrators and developers to remotely access and control servers, transfer files securely, and execute commands securely. SSH is a crucial tool for maintaining the security and integrity of remote systems, making it an essential component of modern computing infrastructure.

In this tutorial, you will enable SSH on Ubuntu 20.04. We will also address some of the FAQs related to SSH.

Advantages of SSH

  1. Secure Remote Access: SSH provides a secure and encrypted method for remote access to servers and computers, protecting against unauthorized access.
  2. Data Encryption: SSH encrypts data transmitted between devices, ensuring confidentiality and safeguarding sensitive information.
  3. Authentication: SSH uses strong authentication methods, including public key authentication, to verify the identity of users connecting to remote systems.
  4. Secure File Transfer: SSH enables secure file transfer between devices, allowing for the safe exchange of files and documents.
  5. Command Execution: SSH allows for secure execution of remote commands, enabling efficient management and administration of servers and systems.

Prerequisite to Install and Enable SSH on Ubuntu 20.04

In order to complete this tutorial, you need to log in as a user with sudo privileges.

Enabling SSH on Ubuntu

You won't find SSH installed on your system by default though you can easily install it from the standard Ubuntu repositories.

1) To begin with, use Ctrl+Alt+T on the keyboard to access your terminal. You can also do this by clicking on the terminal icon. Then, install the openssh-server package using the following command:

sudo apt update
sudo apt install openssh-server

2) After that, enter the password when prompted, then press Y to continue with the installation.

3) The SSH should start automatically once the installation is complete. The following command can help in verifying the status of the SSH service by printing the SSH server status:

sudo systemctl status ssh

You should be able to see Active: active (running)

Then, press q to return to the command line prompt.

4) You need to open the SSH port in case the UFW firewall is enabled.

sudo ufw allow ssh

Connecting to SSH

1) You can connect to a nearby device with the help of the Ubuntu servers using the following command:

ssh username@ip_address
Make sure to change the username with the actual user name and ip_address with the IP Address of the Ubuntu machine where you installed SSH.

2) In case you are unaware of your IP address, you can easily find it using the following command:

ip a

3) Then, log in to the remote server.

You will then see a message which resembles the below output (for the first time you log in through SSH):


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

4) Once you press yes you will be prompted to enter the password:


Warning: Permanently added '<ip>' (ECDSA) to the list of known hosts.
usernampe@ip's password:

You will then be greeted with the following 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 Machine.

Connecting to SSH Over the Internet

The basic piece of information required to access your Ubuntu machine is your public IP address and also how to configure your router to accept data on port 22 then send it to the Ubuntu machine where SSH is running.

You can find out the public IP address by navigating to the following url:

It is recommended that you refer to your router's documentation so that you get a personalized take on setting up port forwarding. The default port for SSH is port 22 which needs to be entered along with the IP address.

You can then log in with the help of the following:

ssh username@public_ip_address

It is also recommended to implement certain security measures, such as configuring your router to accept SSH traffic on a non-standard port and to forward it to port 22 on the machine running the SSH service.

You may also set up an SSH key-based authentication to connect to your Ubuntu machine without entering a password.

Disabling SSH on Ubuntu

In the scenario where you need to disable SSH, you can simply stop the SSH service using the following command:

sudo systemctl stop ssh

To start the SSH service again:

sudo systemctl start ssh

In order to disable SSH service to start during system boot:

sudo systemctl disable ssh

In case you wish to re-enable it, use:

sudo systemctl enable ssh

FAQs to Install and Enable SSH on Ubuntu 20.04

How can I check if SSH is running on my Ubuntu 20.04 system?

Use the command sudo systemctl status ssh to check the status of the SSH service. If it's running, you will see an active (running) message.

Can I change the default SSH port on Ubuntu 20.04?

Yes, you can change the default port for SSH. Open the SSH configuration file using a text editor, locate the Port line, and modify the port number. Save the file and restart the SSH service.

How do I connect to my Ubuntu 20.04 server using SSH?

On another machine, open the terminal and run the command: ssh username@server_ip_address replacing username with your username and server_ip_address with the IP address of your Ubuntu 20.04 server.

How can I generate SSH keys on Ubuntu 20.04?

Use the command ssh-keygen to generate SSH keys on Ubuntu 20.04. It will create a public key and a private key pair, which you can use for secure authentication.

Where are the SSH configuration files located on Ubuntu 20.04?

The main SSH configuration file is located at /etc/ssh/sshd_config. You can modify various settings in this file to customize the behavior of the SSH server.

How can I disable SSH access temporarily on Ubuntu 20.04?

To disable SSH temporarily, use the command sudo systemctl stop ssh to stop the SSH service. Remember to start it again with sudo systemctl start ssh when you need to re-enable it.


We hope this detailed tutorial helped you understand how to enable SSH on Ubuntu 20.04.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.