- Keys, not passwords:
PasswordAuthentication no,KbdInteractiveAuthentication no. - No root login:
PermitRootLogin no; use a normal user with sudo. - Limit who:
AllowUsers alice bob(orAllowGroups ssh-users). - Modern keys: ed25519, a passphrase on the private key, an agent.
- fail2ban to ban repeated failures; keep the system updated.
- A non-default port reduces log noise (it is not real security).
- Test before closing the session: open a second terminal and log in with the new settings,
sudo sshd -tbefore restarting. - Review logins:
last -a | head,sudo journalctl -u ssh --since today | grep -i 'failed\|accepted'.
Put the settings in /etc/ssh/sshd_config.d/99-hardening.conf and check the effective values with sudo sshd -T. Remove keys of people and machines that no longer need access from authorized_keys.