How do you disable SSH password login on a VPS?
Straight answer
To disable SSH password login, first add your public key to ~/.ssh/authorized_keys and check that a key login works. Then put PasswordAuthentication no and KbdInteractiveAuthentication no in a file under /etc/ssh/sshd_config.d/, test with sshd -t and restart SSH. On a BuyMoneroVPS server ordered without a key, it takes about 5 minutes.
In brief
- OpenSSH allows passwords by default: PasswordAuthentication and KbdInteractiveAuthentication both default to yes.
- OpenSSH keeps the first value it reads, and Include files load in lexical order, so a snippet named 00-… wins.
- Always test the key login in a second terminal before restarting SSH.
- A server ordered with a key at BuyMoneroVPS already has password login off.
When do you need this guide?
When the server was ordered without an SSH key and you logged in with the temporary root password. BuyMoneroVPS's checkout makes the key optional. Left empty, a person sets a temporary password for root and shows it in the dashboard, under "Root login with a temporary password". The dashboard itself suggests the next move: add your public key to /root/.ssh/authorized_keys, then turn password login off with PasswordAuthentication no in /etc/ssh/sshd_config.
If you pasted a key at checkout, there is nothing to do: password login is already off and only your key opens root. The SSH key or root password help page explains both cases. No key yet? Create an SSH key on your computer first; it takes two minutes.
What are the steps, without locking yourself out?
Change the temporary password
Log in as root with the password from the dashboard and run passwd at once. The old one stops working and nobody at BuyMoneroVPS knows the new one.
Copy your public key to the server
From your computer, run ssh-copy-id with your key; it asks for the root password one last time and appends the key to /root/.ssh/authorized_keys.
Test the key in a second terminal
Open a new terminal and log in with the key only. Keep the first session open until the end of this guide.
Write the snippet
Create /etc/ssh/sshd_config.d/00-no-passwords.conf with PasswordAuthentication no and KbdInteractiveAuthentication no.
Check the syntax and restart
Run sshd -t. If it prints nothing, restart the ssh service.
Prove that passwords are refused
From your computer, try a login that refuses keys. The server should answer "Permission denied (publickey)" without asking for a password.
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]
ssh -i ~/.ssh/id_ed25519 [email protected]cat > /etc/ssh/sshd_config.d/00-no-passwords.conf <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
EOF
sshd -t && systemctl restart ssh.servicessh -o PubkeyAuthentication=no [email protected]
# expected: Permission denied (publickey).Which sshd settings control password logins?
| Setting | OpenSSH default | Value in this guide | Effect |
|---|---|---|---|
| PasswordAuthentication | yes | no | Refuses plain password logins for every user |
| KbdInteractiveAuthentication | yes | no | Closes the keyboard-interactive path, which can also ask for a password |
| PubkeyAuthentication | yes | yes (unchanged) | Keeps key logins working |
| PermitRootLogin | prohibit-password | unchanged, or no | Default already refuses passwords for root; no blocks root entirely |
Why a snippet in sshd_config.d rather than the main file?
Because snippets are read first, and OpenSSH keeps the first value it finds for each setting. Ubuntu's OpenSSH documentation says files in /etc/ssh/sshd_config.d/ override the main file for that reason. The sshd_config manual adds that Include processes its files in lexical order. A snippet named 00-no-passwords.conf therefore loads before any other snippet, including one that an image may ship with PasswordAuthentication yes.
Editing the main /etc/ssh/sshd_config also works, provided no earlier snippet sets the same option. The snippet approach survives package upgrades that replace the main file, and it is easy to undo: delete one file and restart.
KbdInteractiveAuthentication matters as much as PasswordAuthentication. The manual lists it as a separate method with its own default of yes, so turning off only one of the two leaves the other path open.
What if you lock yourself out anyway?
Keep the first session open until the test login works; if every session is lost, write to support or reinstall with a key. The test in a second terminal is the safety net. If sshd -t reports an error, fix the file before restarting: a broken configuration can stop SSH from starting at all.
Without any working session, write to support. As a last resort, request a reinstall from the dashboard and paste a new public key in "New SSH public key": root then logs in with that key and password login is off from the start. The reinstall erases the whole disk, so it is only for a server with nothing to lose; reboot, reinstall or delete explains each request.
According to BuyMoneroVPS's survey of 30 November 2026, 3 of 14 hosts let you order without an email; BuyMoneroVPS asks for none at all, key or no key. Continue with securing a new Linux VPS for updates and a firewall.
Frequently asked questions
Do I need to restart the server?
No. Restarting the ssh service applies the change; open sessions stay connected. Only new logins follow the new rules.
Should I also set PermitRootLogin no?
It is optional. The default, prohibit-password, already refuses passwords for root while allowing keys. Set it to no only after a named sudo user with a key works.
Does this stop brute-force attempts?
It makes them useless: without password authentication there is nothing to guess. Bots will still knock, which ufw limit or a tool such as fail2ban can quieten.
Can I order a new server with password login already off?
Yes. Paste your public key in the Access step of the checkout. Root then logs in with the key only, and no password is ever set.
Verdict
- Key first, test second, password off third: in that order nothing can lock you out.
- Turn off both PasswordAuthentication and KbdInteractiveAuthentication in an early snippet.
- For the next server, paste a key at checkout and skip this guide entirely.
Sources (3)
- sshd_config(5) manual page — OpenBSD (read 2026-11-30)
- OpenSSH server — Ubuntu Server documentation (read 2026-11-30)
- ssh-keygen(1) manual page — OpenBSD (read 2026-11-30)
Order with your key, no password ever
Ring 1: 1 vCPU · 1 GB memory · 20 GB NVMe disk · 2 TB monthly transfer. Paste your public key at checkout, pay in Monero.