How do I disable SSH password authentication?

If you have set up your Linux server to authenticate using an SSH key, it is recommended to completely disable password authentication. This greatly reduces the attack surface for your server.

Manually via SSH

Disabling password authentication is actually quite simple. Open the configuration file /etc/ssh/sshd_config with a text editor (e.g. nano).

Find the line

#PasswordAuthentication yes

Remove the “#” in this line. Replace “yes” with “no” at the end, so it should read:

PasswordAuthentication no

Save the file and restart the SSH server. You can do this with the command:

service ssh restart

Keep the current SSH session open and open a new session in a new window. Now, try to log in using the SSH key. If it doesn’t work, you should re-enable password authentication and resolve this issue.

Using the web interface

In the Cloud Manager, you can easily enable or disable password authentication in the VPS settings.

Go to the “SSH” tab and select the option “SSH Key Only” for “Root Login”.

Login with SSH Key only. Disable password authentication.

After saving, your server will only allow root login with an SSH key.

I have locked myself out of SSH

If you have locked yourself out, you can always connect to your server using VNC. There you can also use the root password, as it is not an SSH connection but a direct terminal connection. Otherwise, our support team is always available to assist you.

Leave a Reply

Your email address will not be published. Required fields are marked *