Apr 23, 2025
Linas L.
2min Read
The majority of people use password authentication to connect to their servers via SSH command line and do not even consider that this authentication method may not be as safe as they expected. Consider this: if any hacker manages to collect your SSH password, all of your valuable information is at risk. That is why authenticating with SSH keys is a better option.
In this tutorial you will learn how to disable password authentication for SSH on Linux VPS.
Download ultimate SSH commands cheat sheet
Before you begin this guide you’ll need the following:
Before we start the guide, you should note that if you do not set up another authentication method beforehand and disable password authentication right away, you will have a hard time connecting to your server.
Important! Configure another way of authentication before you proceed with this guide. We recommend SSH Key authentication. Continue with this tutorial only after you configure your SSH Keys because you may be locked out of your own server.
Proceed with this only if you have completed Step 1 and successfully connected to your VPS using [SSH keys] because you may be locked out of your own server.
nano /etc/ssh/sshd_config
PasswordAuthentication yes. Nano has a search feature so you can simply search for this line by pressing CTRL + W on your keyboard, writing a search keyword PasswordAuthentication and clicking Enter.

PasswordAuthentication yes to PasswordAuthentication no:
service sshd restartAnd that is it! SSH password authentication has been disabled. From this point no one will be able to connect to your server / VPS using SSH password. Only privileged users who have their SSH keys added to your server will be able to connect.
You have learned how to disable SSH password authentication on your server / VPS. This makes your server a lot safer because no one will be able to connect to your server via SSH using a password. Only privileged users using SSH keys or other advanced authentication methods will be able to connect.

All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.