How to enable ssh on Ubuntu 20.04 LTS Linux

SSH ( Secure Shell ) is a standard network instrument used to access personal computer and other systems remotely but in a secure way. here we let you know how to enable SSH on Ubuntu and use it using Authentication keys .
What is SSH?
SSH, or Secure Shell, means both a network protocol and the software required for its use. It works on a dedicate interface number that is 22. Hence, to use SSH on Ubuntu or any early system port 22 must be allowed in the system firewall .
The estimate behind using SSH is to establish a secure connection with another calculator in the network. however, the remote control computer must have a run SSH server, otherwise, we won ’ t be able to connect it using command or SSH customer from our local computer.

adenine soon as we have established a connection, a prompt will happen to enter the password of the outback PC user to get logged in and entree the same in completely code shape. The result of a connection is always identical. You end up in a command line on the computer, logged in as one of the users there .
furthermore, we don ’ t need a personal computer to connect, tied a smartphone can be used. SSH besides allows controlling computers without Display such as NAS boxes, routers, and more…
This network tool is not barely limited to Ubuntu only, we can use it on macOS, Windows, Rasberry Pi, and others tied on smartphones…

install and Enable Open SSH Server on Ubuntu 20.04

Most of the clock time Ubuntu comes by default with SSH as an OpenSSH server & the customer is already installed in it. however, if you don ’ t have then follow the below-given steps. This tutorial is applicable for all active Ubuntu systems such as Ubuntu 18.04/19.04/21.04 ,

  • Run system update command- sudo apt-get update
  • Install OpenSSH server on Ubuntu 20.04  LTS-
    sudo apt-get install openssh-server openssh-client
  • Enable and Start SSH server services on Ubuntu: sudo systemctl enable --now ssh
  • To check the status run- systemctl status ssh

Enable SSH server on Ubuntu 20.04 Check SSH server status on Ubuntu
once the initiation is completed, we can test it by connecting our Ubuntu 20.04 LTS system remotely via SSH using the local computer which can be a virtual machine. Of course, one thing you have to make sure your local anesthetic arrangement should be able to reach the distant system that you want to connect via the network .

How to Connect remote Ubuntu system via SSH

Let’s see how to use your local system’s command prompt or terminal to connect the remote Ubuntu system using SSH.  here we are assuming that a outback Ubuntu system has an Ip-address- and the username is h2s ; now to establish the connection via ssh follow the below steps :

  1. Open a terminal in your Linux or Command prompt in the Windows system.
  2. Use the command syntax “ssh [email protected]“. For example- ssh [email protected].
  3. Since we have not connected our Ubuntu server before where we have installed the SSH server, hence, the computers do not “know” each other, of course.
  4. Therefore, when we connect the server for the first time, it will ask whether you really want to connect to the computer and whether you trust the displayed signature. Simply confirm by typing ” yes “.
  5. After that you the process will ask for the password of the remote user, defined in the command while connecting the server. Enter the password and with that, you will get the command line of the remote server to issue commands remotely. To leave this again, type ” exit “.

SSH command to connect remote Ubuntu 20.04 Server

Key authentication for more security

good, rather of entering the password of the remote control Ubuntu server, we can use a more secure way that is Key. In which we don ’ t need to enter a plain password, therefore prevent our password from getting leaked or copied, in case we are using some stranger computer to connect the outback server .
The rationale of using a key is actually very elementary. We fair need to create a key pair on the node car based on the concept of the public and private keys. thus, basically, we will create two keys one is the Public key that is used to encrypting the plain text to convert it into ciphertext whereas the Private key is used by the recipient to decrypt the ciphertext to read the message .
In dim-witted words, the private key is like a Door key that must remain secret as you can use it to unlock the doorway to the outside calculator. The public key is basically the keyhole that you build into the door of the server. Hence, the concept is similar to real doors present in our houses, everyone can see the Door ’ s keyhole but the Key to open is only with the Owner of the theater .

Generate Public and Private Keys for SSH

  • Open command line- Terminal or Prompt on your local system.
  • Enter SSH key generator command that will generate the  key ssh-keygen
  • Hit the Enter key.
  • (optional) Then you can enter a password in order to add an additional barrier when establishing the connection. Otherwise, simply press the Enter key two times, if you don’t want the system to ask for an additional password query.
  • Ultimately, two files are created in the hidden directory “.ssh” under your user directory: “id_rsa” and “”. The “rsa” in the file name stands for the cryptography used, but you don’t have to worry about it. The file extension “pub” stands for “Public”, so it is the public key. Whereas the file without any extension is your private key.

Generate SSH Public and Private Keys
Go to the folder displayed on the command terminal to access the keys:

Access Secure Keys

Copy Public key to Server

now, to establish a connection using the Key pairs, copy your generate Public key to the waiter which is Ubuntu hera .
We don ’ t need to visit the waiter manually, we can use SSH for copying the key equally well .
Use the following command top copy SSH Public key to Server:
On Linux 

ssh-copy-id -i ~/.ssh/ username@ip-address 

Note : Change the username and Ip-address with the actual values of your distant server .
On Windows
Note : Replace windows-username with your current drug user under which the public key has been saved, whereas the [email protected] needs the distant Linux user and IP-address .
On macOS:

brew install ssh-copy-id
ssh-copy-id -i ~/.ssh/ username@ip-address 

The ” -i ” indicates that the identity is to be copied, which means the assign public key. Copying is of class done via SSH, hence we need the password distant machine once, here .
once the Key has been copied, you can use your private cardinal to connect distant see a system without entering any kind of password. however, make indisputable your secret keystone is in a condom localization where it can be accessed by you entirely .
To use private, here is the command syntax:
path-to-private-key: Replace it with the way where you have saved the private key generated by you .
Whereas, the username and IP address are for the distant waiter system details .
In this way, we can use authentication keys to get a passwordless connection, keep one thing in beware, it is alone potential if you have your private key file with you. Know more about SSH at official web site.

Related Posts

Leave a Reply

Your email address will not be published.