October 21, 2021
How to enable SSH protocol On Ubuntu 20.04

How To Enable SSH on Ubuntu 20.04

On this article we will learn how to enable SSH services on Ubuntu 20.04 LTS operating system.

Introduction

It is undeniable, we need a connection between computers to be able to exchange the information we need. Security when the connection occurs must be maintained both from the server and client side. For this purpose, we need a protocol that can guarantee the security of data transmission between nodes, which is referred to as SSH. Secure Shell (SSH) is a network protocol used for a secure connection between a client and a server. Each connection between the server and a client is encrypted. This article explains how to enable SSH on an Ubuntu 20.04 LTS system.



Enabling Secure Shell (SSH) on Ubuntu 20.04 LTS

By default, the fresh installed Ubuntu system is not allowing remote access via SSH, so we have to enable it first. Enabling SSH protocol will be explained below:

  1. System Update
  2. Installing SSH
  3. Setting Firewall
  4. Test Connection From Other server

1. System Update

By updating our system, it will refresh the local list of available packages software to the newer stable version. To update Ubuntu 20.04 system repositories, we will use the command line: sudo apt update.

ramansah@app01:~$ sudo apt update
[sudo] password for ramansah: 
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 https://dl.winehq.org/wine-builds/ubuntu focal InRelease                                                                        
Hit:3 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease                                                                    
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                                                             
Hit:6 http://us.archive.ubuntu.com/ubuntu focal InRelease                                            
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]       

2. Installing SSH

To install and enable SSH, we will typing the command line : sudo apt install openssh-server.

ramansah@app01:~$ sudo apt install openssh-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dbconfig-common gsfonts imagemagick-6-common libaio1 libcgi-fast-perl libcgi-pm-perl libdbi-perl libfcgi-perl libfftw3-double3
  libfprint-2-tod1 libhtml-template-perl libjs-chart.js libjs-jquery-ui libjs-raphael liblqr-1-0 libmagickcore-6.q16-6 libreadline5
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  ncurses-term openssh-client openssh-sftp-server ssh-import-id
Suggested packages:
  keychain libpam-ssh monkeysphere ssh-askpass molly-guard
The following NEW packages will be installed:
  ncurses-term openssh-server openssh-sftp-server ssh-import-id
The following packages will be upgraded:
  openssh-client
1 upgraded, 4 newly installed, 0 to remove and 140 not upgraded.
Need to get 1,359 kB of archives.
After this operation, 6,010 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y

After the installation is complete, the SSH service will start automatically. We should verify if SSH is running properly by typing : sudo systemctl status ssh.

ramansah@app01:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-09-02 02:34:37 PDT; 1min 30s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 4363 (sshd)
      Tasks: 1 (limit: 9448)
     Memory: 1.3M
     CGroup: /system.slice/ssh.service
             └─4363 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

Sep 02 02:34:37 app01.otodiginet.com systemd[1]: Starting OpenBSD Secure Shell server...
Sep 02 02:34:37 app01.otodiginet.com sshd[4363]: Server listening on 0.0.0.0 port 22.
Sep 02 02:34:37 app01.otodiginet.com sshd[4363]: Server listening on :: port 22.
Sep 02 02:34:37 app01.otodiginet.com systemd[1]: Started OpenBSD Secure Shell server.

3. Setting Firewall

On this section we will set the firewall to allow SSH connection. By defatul, Ubuntu ships with a firewall configuration tool called UFW. If the firewall is enabled on our system, we have to open the SSH port, by typing command line : sudo ufw allow ssh.

ramansah@app01:~$ sudo ufw allow ssh
Rules updated
Rules updated (v6)

4. Test Connection From Other Server

On this section, we will try to make a connection from other server to the our server which was SSH Enabled. For this purpose we will identify our server IP Address, by typing command line : ssh username@ip_address. (Note Our IP Address server : 192.168.19.139).

[root@otodiginet ~]# ssh ramansah@192.168.19.139
Enter passphrase for key '/root/.ssh/id_rsa': 
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.8.0-59-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

111 updates can be applied immediately.
48 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

Your Hardware Enablement Stack (HWE) is supported until April 2025.
Last login: Thu Sep  2 02:40:26 2021 from 192.168.19.139
ramansah@app01:~$ 

We will be asked to supply the password, and will be prompted to the console.

Conclusion

On this article we have shown you how to enable SSH protocol on Ubuntu 20.04 LTS operating system. I hope this simple article will be useful for anyone who search information about enabling SSH.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *