TL;DR: How to set up SSH key login and turn off password login
The fix only. No explanation, no diagnosis. Read the full article if any of this does not match what you are seeing.
- On your own machine, make a key with a passphrase:
ssh-keygen -t ed25519 -C "you@yourpc" - Install the public key on the server (Linux, macOS), then log in with it from a NEW terminal:
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server
ssh -o PreferredAuthentications=publickey user@server- On the server, create
/etc/ssh/sshd_config.d/00-keys-only.confcontainingPasswordAuthentication no,KbdInteractiveAuthentication noandPermitRootLogin no. - Validate, check the effective values, then reload (
sshon Debian/Ubuntu,sshdon RHEL/Fedora/Arch):
sudo sshd -t
sudo sshd -T | grep -Ei '^(passwordauth|kbdinteractive|permitroot)'
sudo systemctl reload ssh- From a third terminal, confirm the key still works and a password is refused.
Keep your first working session open until step 5 passes. If it fails, fix it from that session. Know where the server console is before you start.