Once your keys are working, you can disable password authentication to prevent people and bots from trying to guess your password. We will be using Nano for this, so make sure you have it installed. If you prefer a different editor that's perfectly fine. If you do not have Nano installed please follow this article to learn how to set it up.

Open the SSHD config file in Nano or other editor:

nano /etc/ssh/sshd_config

Press CTRL + W (CMD + W on Mac) to open the Search function and type in passwordauthentication and press Enter to search. You will be using your arrow keys to navigate the cursor.

Find a line that says "#PasswordAuthentication yes" (or similar) and edit it so that it says "PasswordAuthentication no" without the # sign on the beginning. If the line couldn't be found by Nano, you are welcome to add it, preferably at the bottom of the file.

Press CTRL + X (CMD + X on Mac) to exit and save changes by pressing Y and then Enter.

Then, restart the SSHD service: (CentOS, Fedora, CloudLinux, Red Hat Enterprise Linux...)

service sshd restart

On Ubuntu, Debian, Arch:

service ssh restart

Once this is done password authentication for SSH should be disabled.

Need help?