A short SSH hardening checklist
The basics, in the order I apply them on a new server:
- Add your public key and confirm you can log in with it.
- Set
PasswordAuthentication noin a drop-in under/etc/ssh/sshd_config.d/. - Use
PermitRootLogin prohibit-passwordor a separate user. - Install fail2ban with an incremental ban time.
Always keep a second session open while you restart sshd, and keep console access handy in case you lock yourself out.