🖧 Sysadmin 1 min read

Hardening SSH on a Linux server in 10 minutes

SSH is the front door of your server, so lock it down properly.

Configure sshd_config

# /etc/ssh/sshd_config.d/99-hardening.conf
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
MaxAuthTries 3
AllowUsers deploy

Check the syntax, then reload:

sudo sshd -t && sudo systemctl reload ssh

Fail2ban

sudo apt install fail2ban
sudo systemctl enable --now fail2ban

⚠️ Always keep one SSH session open while testing a new configuration so you don’t lock yourself out.