How to Disable Password Login for VPS (Ubuntu/Debian)
Disable password login and enforce SSH key authentication for better VPS security. This guide applies to Ubuntu, Debian, and similar Linux distributions.
Prerequisites
-
VPS with Ubuntu/Debian OS.
-
Root SSH access with SSH Key Authentication enabled.
-
(Need help? See: Setup SSH Key Authentication)
-
Steps to Disable Password Login
1. SSH into Your VPS
ssh root@your_server_ip
2. Edit SSH Config
Open SSH config:
nano /etc/ssh/sshd_config
Find and set:
PasswordAuthentication no
PermitRootLogin prohibit-password
3. Reload SSH
systemctl reload sshd
4. Test Login in New Terminal
Before logging out, open a new SSH session and verify you can still login via SSH key:
ssh root@your_server_ip
5. Done
Password logins are now disabled. Only SSH key logins are accepted.
Notes
-
Always test in a new terminal to avoid being locked out.
-
Use Console/Serial access if SSH access fails.
Related
