Disabling Password Authentication
What You'll Learn
You'll learn why password-based SSH authentication is vulnerable and how to enforce public key authentication for stronger security.
The Problem with Password Authentication
Password authentication over SSH is like using a physical key with only three pins—easy to pick. Attackers can:
- Brute-force passwords by trying thousands of common combinations
- Credential stuff using leaked passwords from other breaches
- Exploit weak passwords chosen by users despite policies
- Leverage stolen passwords from keyloggers or phishing
Even with a strong password policy, passwords remain the weakest link because they can be guessed, intercepted, or stolen.
Enforcing Public Key Authentication Only
Public key authentication (covered in your SSH fundamentals lesson) requires possession of a private key file—something an attacker can't simply guess. It's like replacing a pickable lock with a biometric scanner.
To disable password authentication, edit /etc/ssh/sshd_config:
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no
Then restart the SSH service:
sudo systemctl restart sshd
Before disabling passwords, ensure you have:
- Generated SSH key pairs
- Deployed public keys to authorized users'
~/.ssh/authorized_keys - Tested key-based login successfully
Otherwise, you'll lock everyone out—including yourself.
Why This Matters
This single configuration change eliminates entire classes of attacks. Brute-force attempts become impossible because there's no password to guess. Combined with other SSH hardening (binding to specific IPs, service isolation), you dramatically reduce your attack surface.
Key Takeaway: Disabling password authentication in sshd_config forces public key authentication, eliminating brute-force and credential stuffing attacks while requiring attackers to possess actual key files—vastly improving SSH security.