Set Up SSH Keys On Ubuntu 18.04
SSH is an encrypted protocol used to Admin and communicate with servers. When working with an Ubuntu server, most of your time in a terminal session connected to the server through SSH.
In this guide, I use a Pem file to SSH the server without password on Ubunto 18.04
To SSH using pem file, there are some of the following steps:
Step 1 — Create the Key Pair
The first step is to generate an RSA key pair by typing the following at a shell prompt:

After entering the command, you should see the following output:

Type ubuntu_ssh, You should then see the following prompt:

Press Enter (empty passphrase). Then You should then see the following output:
Then type:

Here we will get two files generated: ubuntu_ssh and ubuntu_ssh.pub . Then, rename ubuntu_ssh to ubuntu_ssh.pem, by typing:

So, you will have two files, ubuntu_ssh.pub and ubuntu_ssh.pem
Step 2 — Add Public Key to Ubuntu Server
Type this into your local computer, to get the public key:

Then, you should see the output like this:

Access your remote host using whichever method you have available. (Here I access via ssh with password)
Make sure the ~/.sshdirectory exists, if not exists, type this:

Create a file ~/.ssh/authorized_keys if already exist ignore this step

Then copy and paste your public key in to this file. — Save&Exit
Finally, need to change the permissions of the ~/.ssh/authorized_keys file using the following command:

Step 3— Using Key-Based Authentication
To improve the system security even further, you can enforce key-based authentication by disabling the standard password authentication. To do so, open up the SSH daemon’s configuration file:

In this file, change or uncomment if exist the option as follows:

To actually implement these changes, we need to restart the sshd service:

Step 4 — Now access the server by ssh through pem file ( without password ) from local
Finally, here is what we’re expecting:

Last by not least, I hope you find this useful!
