4 Steps to Setup SSH (OpenSSH) on Ubuntu 20.04 LTS

SSH is a free & open source remote connectivity tool. SSH stands for Secure Shell. It is a cryptographic network protocol & used for a secure connection between a client and a server. It helps to access remote machine & securely transfer files or perform administrative tasks.

There are some steps to setup SSH on ubuntu:

Step 1: Update the System.

apt-get update

Step 2: Install OpenSSH on system.

apt install openssh-server

  • Check the Status of SSH.

systemctl status ssh

  • Here is the command output.

[email protected]:/home/ubuntu# systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/ssh.service.d
Active: active (running) since Sat 2021-10-23 08:25:35 UTC; 3min 10s ago
Docs: man:sshd(8)
Main PID: 718 (sshd)
Tasks: 1 (limit: 4706)

Step 3: To allow ssh on firewall.

ufw allow ssh

  • Here is the command output.

[email protected]:/home/ubuntu# ufw allow ssh
Rules updated
Rules updated (v6)

  • Check the status of UFW.To check,it is enabled or not.

ufw status

  • Here is the command output.

[email protected]:/home/ubuntu# ufw status
Status: inactive

  • To enable the ufw.

ufw enable

  • Here is the command output.

[email protected]:/home/ubuntu# ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

  • Now, Again check the ufw status.

ufw status

  • Here is the command output.

[email protected]:/home/ubuntu# ufw status
Status: active
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)

Step 4: Login to Remote machine/server by using SSH.

  • To find the ip address.

ip a

  • Run the following command:

ssh [email protected]
ssh [email protected]

For example:

ssh [email protected]

  • Here is the command output.
  • Type Yes.
  • Provide the remote server user password.
  • Press Enter.

ro[email protected]:/home/ubuntu# sudo ssh [email protected]
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:/kKKIibipKtEoz/45nisv2DMjoQ2AT3OLZORQfrKk/8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
[email protected]'s password:
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
1 update can be applied immediately.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
[email protected]:~$

  • Now,Successfully login in Remote Server.


Leave a Reply