Adding SSH Public Key and Disable SSH Password Authentication
Paste the SSH Public key inside the authorized_keys file in the .ssh folder of the user’s home directory.
mkdir ~/.ssh
#Use your perferred text editor to create the authorized_keys file; here I am using nano
nano ~/.ssh/authorized_keys
Edit the sshd_config and set PasswordAuthentication to no
sudo nano /etc/ssh/sshd_config
You can also use the following one liner to change the PasswordAuthentication to no:
sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config