# Disable SSH password authentication

> Canonical: https://jethost.com/kb/disable-ssh-password-authentication/ · Last modified: 2026-08-20T06:50:23+00:00

Choosing to **disable SSH password authentication** is one of the most effective ways to secure your VPS. Once only SSH keys are allowed, automated bots can no longer brute-force your password, because there is no password login to attack. In this guide, we will show you how to disable SSH password authentication on your server, step by step.

**Important:** before you start, confirm your SSH key login already works. If your keys are not set up correctly and you disable passwords, you will be locked out of SSH.

## Edit the SSH configuration file

First, connect to your VPS over SSH and open the SSH server configuration file with an editor such as `vi` or `nano`:

```
nano /etc/ssh/sshd_config
```

## Allow key-based login

Next, confirm that public key authentication is enabled. Find this line, make sure it reads `yes`, and remove the `#` if it is commented out:

```
PubkeyAuthentication yes
```

## Turn off password authentication

Now find the `PasswordAuthentication` line and change its value from `yes` to `no`. This is the step that actually disables SSH password authentication:

```
PasswordAuthentication no
```

Save the file and close the editor. On some systems the same setting can also appear inside a file in `/etc/ssh/sshd_config.d/`, so if password login still works afterwards, check there for an override and set it to `no` as well.

## Restart the SSH service

Finally, apply the change by restarting the SSH service:

```
systemctl restart sshd
```

Before you close your current session, open a second terminal and test that you can still log in with your key. Keeping the first session open means you can undo the change if anything goes wrong. Your SSH server is now locked down to key-based access only.

## Need more help?

Explore more [Linux commands](https://jethost.com/kb/category/linux-commands/) and server tips, and run a fully managed environment with root access on a [JetHost VPS](https://jethost.com/vps/). With full SSH and terminal control, you can disable SSH password authentication and harden your server exactly the way you want.
