Setup Ssh Ubuntu 20.04



  1. Ubuntu 20.04 Setup Ssh
  2. Install Ssh On Ubuntu 20
  3. Config Ssh Ubuntu 20.04

SSH (Secure Shell) is an encrypted protocol which allows client system to communicate securely with a server. You can connect to your system remotely, perform administrative tasks and access files. It’s more secure way to communicate with server using SSH keys than password authentication. This tutorial explains how to create SSH keys on Ubuntu 20.04 Focal Fossa.

Create SSH keys on Ubuntu#

In this tutorial, you will learn how to configure the firewall with UFW on Ubuntu Linux 20.04 LTS server or desktop to protect system from attacks. How to Enable SSH in Ubuntu 20.04 - Install ssh serveropenssh fix remote ssh issue.

Before you start, make sure you are logged in as root or user with sudo privileges.

Step 1 – Create Key Pair#

At first, we will create a key pair on client system using below command:

By default, latest version of ssh-keygen will generate 3072-bit RSA key pair. If you wish to create larger 4096-bit key then pass -b 4096 in flag.

Above command should show output like below:

Hit the Enter key to save the key pairs at ./ssh directory or you can specify location as per your choice.

Next, it will prompt to enter a secure passphrase. Passphrase will add an additional security layer to your keys. It is optional, whether you want to set or skip it by just hitting Enter key.

Next, you will see output as following:

Now you have public and private keys which you can use to authenticate with your Ubuntu server.

You also can verify that your files are generated or not by typing:

It will show output like this:

Step 2 – Copy Public Key to Server#

Next step is to place public key to your Ubuntu server. Simple and fast way to copy public is to use ssh-copy-id utility. Run the below command:

You will be prompted to enter password for your username:

Once the user is authenticate successfully, the public key will be appended to ~/.ssh/authorized_keys file on remote user and connection will be disconnected.

If your local system don’t have ssh-copy-id utility installed then you can use following command to copy the public key:

Ensure that you have password-based SSH access to your server then only you can use above method.

Step 3 – Login to the Server using SSH Keys#

Seagate backup plus hub 8tb stel8000401. Now, you should be able to login to the remote machine without the remote user’s password.

Try to connect using SSH command:

If you are first time to login then it may prompt you as following. Type yes and hit Enter key to continue:

Now, if you haven’t set passphrase for your keys then you will be logged in immediately without asking passphrase. Otherwise it will be asked to enter passphrase. After successful authentication, a new shell session will open your user account on the Ubuntu server.

Setup ssh ubuntu

Step 4 – Disable SSH Password Authentication#

You can add one more security layer by disabling the password authentication for SSH. Before starting process, make sure that you are able to authenticate to your server without entering password and must have sudo enabled user account.

Let’s login to your server using ssh:

Now edit the SSH configuration file located at /etc/ssh/sshd_config:

Find PasswordAuthentication directive and if line commented out then uncomment the line and set the value to no as given below:

Save and close the file. Metal slug 6 plus. You must need to restart the SSH service using below command:

At this point, password-based authentication is disabled on your Ubuntu server.

Conclusion#

You learned how to create a new SSH keys pair and set up an SSH key-based authentication on Ubuntu 20.04 machine. You can set up same key to multiple remote hosts. At the end, you also learned how to disable SSH password authentication.

By default, SSH listens on port 22. You can reduce the risk of automated attacks by changing the default SSH port.

Ubuntu 20.04 Setup Ssh

Openssh ubuntu 20

If you have any question or suggestion, please leave comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

When you connect to a host via SSH, you’ll be asked for your password, and after you authenticate you’ll be connected. Instead of using your password though, you can authenticate via Public Key Authentication instead.

The benefit to this is added security, as your system password is never transmitted during the process of connecting to the server.

Creating SSH keys

Install Ssh On Ubuntu 20

Step 1 : you’ll first need to generate your key. To do so, use the ssh-keygen command as your normal user account.

  • First, you’ll be asked for the directory in which to save your key files, defaulting to /home/user/.ssh.
  • You’ll next be asked for a passphrase, which is optional. You can press Enter for the passphrase without entering one if you do not want this.

Step 2: It will create two files, id_rsa and id_rsa.pub.

  • The id_rsa file is your private key.
  • id_rsa.pub : The public key is the key that gets copied to other servers to facilitate you being able to log in via the key-pair. When you log in to a server that has your key, it checks that it’s a mathematical match to your private key, and then lets you log in

Copy the Public Key to the Server

Config Ssh Ubuntu 20.04

Step 1 : To actually transmit your public key to a target server, we use the ssh-copy-id command. In the following example, I’ll show a variation of the command that’s copying the key to a server administrator@192.168.2.95

Step 2 : The contents of ~/.ssh/id_rsa.pub on your machine are copied into the ~/.ssh/authorized_keys file on the target server. With each additional key you add (for example, you connect to that server from multiple machines), the key is added to the end of the authorized_keys file, one per line.

Step 3 : Authenticate to your Server Using SSH Keys