Skip to main content

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

Screenshot 2022-04-15 231407.png

Screenshot 2022-04-25 231526.png

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

image.png

image.png