/etc/ssh/sshd_config.d/00-disable-passwords.conf containing PasswordAuthentication no and KbdInteractiveAuthentication no, check the config with sudo sshd -t, then restart SSH with sudo systemctl restart ssh (Ubuntu/Debian) or sudo systemctl restart sshd (AlmaLinux/Rocky). Confirm a key login works first and keep your current session open until you have tested a new one.
Before you start
- You must already log in with an SSH key. If you haven’t set one up, follow create and use SSH keys first.
- Test it:
ssh -o PasswordAuthentication=no alex@203.0.113.10must log you in. - Keep one SSH session open the whole time. It stays connected when you restart SSH and is your way back if something goes wrong.
- Commands use
sudo. If you are logged in as root, leavesudoout.
Why use a file in sshd_config.d?
Current Ubuntu, Debian, AlmaLinux and Rocky Linux releases start/etc/ssh/sshd_config with Include /etc/ssh/sshd_config.d/*.conf. OpenSSH uses the first value it reads for each setting, and included files are read in alphabetical order. Many server images ship a file such as 50-cloud-init.conf that sets PasswordAuthentication yes. A file whose name starts with 00- is read before it, so your setting wins, and package updates don’t overwrite it.
How to disable password login
1
Check what is set now
2
Create the override file
KbdInteractiveAuthentication covers the “keyboard-interactive” method, which can also ask for a password. Turning off both stops all password prompts.3
Test the configuration
4
Restart SSH
- Ubuntu / Debian
- AlmaLinux / Rocky
5
Test from a new window
Open a second terminal and log in with your key. It should work as before.
How to check it worked
Confirm the active settings:How to turn password login back on
Delete the file and restart SSH:sshd instead of ssh in the restart command on AlmaLinux and Rocky Linux.
Frequently asked questions
I set PasswordAuthentication no but passwords still work. Why?
Another file sets it toyes first, usually a 50-cloud-init.conf in /etc/ssh/sshd_config.d/, or a line near the top of sshd_config. Run sudo sshd -T | grep passwordauthentication to see the value SSH really uses, and make sure your file name sorts first.
Does this also block root logging in with a password?
Yes, it blocks password logins for every user, including root. To stop root logging in at all, see disable root login over SSH.Can I still use the VNC console with a password?
Yes. This setting only affects SSH. The VNC console is a local login and still accepts your password.Do I still need Fail2ban after disabling passwords?
Password guessing can no longer succeed, but bots still fill your logs. Fail2ban or CrowdSec blocks them early.Related guides
VPS and dedicated server guides
Every guide in this section.
Create and use SSH keys
Set up key login first.
Change the SSH port
Cut down automated scans.
Disable root login
Log in as a normal user instead.
Linux security checklist
Everything to harden on a new server.
Checked against the official OpenSSH sshd_config manual on 4 November 2026; the drop-in file,
sshd -t, sshd -T and the refused password login were tested with OpenSSH 9.6 on Ubuntu 24.04 LTS. File names in sshd_config.d can differ between server images.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026