No brute-force protection
MediumL09Linux serversTurn on fail2ban so an IP that fails to log in several times is blocked for a…
What is the risk
Without protection, attack tools guess passwords nonstop. Logs fill up and weak accounts eventually fall.
How to check
Linux
systemctl is-active fail2ban
sudo fail2ban-client status sshdHow to fix
Debian / Ubuntu
sudo apt install fail2banRHEL / Rocky / Alma
sudo dnf install epel-release
sudo dnf install fail2banFor Rocky and Alma. On RHEL enable the EPEL repository first.
Linux
printf '[sshd]\nenabled = true\nmaxretry = 5\nfindtime = 10m\nbantime = 1h\n' | sudo tee /etc/fail2ban/jail.local
sudo systemctl enable --now fail2ban
sudo systemctl restart fail2banFive failures in 10 minutes block the IP for an hour. If it fails to start on servers without /var/log/auth.log (such as Debian 12), add backend = systemd under [sshd].
How to prevent it
- With key-only SSH (L02), guessing does not work at all.
- Add your office IP to ignoreip in jail.local so you never lock yourself out.
Check again after fixing
Linux
sudo fail2ban-client status sshdRun the downloaded check again and make sure this item passes.