← Knowledge Base
CybersecurityReference note1 min read · updated 2026-11-27

SSH hardening checklist

Keys only, no root login, limited users, fail2ban, updates and monitoring of logins.

sshhardeningsecurity
  1. Keys, not passwords: PasswordAuthentication no, KbdInteractiveAuthentication no.
  2. No root login: PermitRootLogin no; use a normal user with sudo.
  3. Limit who: AllowUsers alice bob (or AllowGroups ssh-users).
  4. Modern keys: ed25519, a passphrase on the private key, an agent.
  5. fail2ban to ban repeated failures; keep the system updated.
  6. A non-default port reduces log noise (it is not real security).
  7. Test before closing the session: open a second terminal and log in with the new settings, sudo sshd -t before restarting.
  8. 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.