Tools
Log in
English

Learn to codeSecurity check

No brute-force protection

MediumL09Linux servers

Turn 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 sshd

How to fix

Debian / Ubuntu

sudo apt install fail2ban

RHEL / Rocky / Alma

sudo dnf install epel-release
sudo dnf install fail2ban

For 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 fail2ban

Five 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 sshd

Run the downloaded check again and make sure this item passes.

Security check home