ยท 1 min read
Enable password login for SSH on a VPS
Some images ship key-only SSH. Here is how to switch password authentication back on without locking yourself out.
Many VPS images disable password authentication by default. If all you have is a password, or you are recovering an account with no key installed yet, you need to turn it back on.
Check what the server allows right now
sudo sshd -T | grep -i passwordauthentication
sshd -T prints the effective configuration, including values pulled in from files under /etc/ssh/sshd_config.d/. If the answer is passwordauthentication no, an override somewhere is setting it.
Edit the configuration
sudo nano /etc/ssh/sshd_config
Set:
PasswordAuthentication yes
ChallengeResponseAuthentication yes # older releases
KbdInteractiveAuthentication yes # OpenSSH 8.7 and newer
ChallengeResponseAuthentication was renamed to KbdInteractiveAuthentication; on recent releases only the new name is read. Setting both is harmless on older systems and ignored on newer ones.
Restart SSH
sudo systemctl restart ssh
# or, on older images
sudo /etc/init.d/ssh restart
Restarting does not drop your current session, which is exactly why you test from a second terminal:
ssh [email protected]
Only close the original session once the new one authenticates with a password. If it fails, the server is still reachable through the session you kept open.
A note on root
If you also plan to allow root logins, change PermitRootLogin deliberately rather than by accident. prohibit-password keeps root key-only, which is what most people actually want.