SSH hardening checklist for Debian and Ubuntu servers
Key-based logins, restricted access and sensible defaults: a practical checklist for Linux servers.
Minty Security team · 2 October 2026SSH is the front door of almost every Linux server and is attacked by bots around the clock. These settings make that door considerably stronger.
Always test changes in a second, open session before closing your current one, so you don't lock yourself out.
In /etc/ssh/sshd_config
PasswordAuthentication no: key-based logins only.PermitRootLogin no: log in as a regular user and usesudo.KbdInteractiveAuthentication noAllowUsers deploy admin: only named accounts may log in.MaxAuthTries 3andLoginGraceTime 30
Validate the configuration with sudo sshd -t, then reload with sudo systemctl reload ssh.
Keys
- Use Ed25519 keys protected by a passphrase.
- Remove keys of people who no longer need access from
~/.ssh/authorized_keys.
Network
- Only allow SSH through the firewall from trusted IP addresses or via a VPN.
- Consider Fail2ban to temporarily block repeated failed attempts.
Maintenance
- Install security updates automatically with
unattended-upgrades. - Periodically review
journalctl -u sshfor unusual logins.
Want to know how your website is doing?
Take the free Website Security Check or get in touch for a full assessment.