security.frabs.net
All Guides

Login Attacks · about 10 minutes

Block Repeat Login Attackers With fail2ban

What This Means

Nothing stops an address that keeps failing to log in from trying again and again.

Why It Matters

fail2ban watches the login log and blocks an address after a few failures, which stops most password guessing.

  1. 1

    Install fail2ban

    apt install -y fail2ban
    Terminal: Install fail2ban, on Ubuntu 24.04
  2. 2

    Protect SSH

    jail.local holds your settings and survives updates. This blocks an address for an hour after 5 failures in 10 minutes.

    printf '[sshd]\nenabled = true\nbackend = systemd\nmaxretry = 5\nfindtime = 10m\nbantime = 1h\n' > /etc/fail2ban/jail.local
    Terminal: Protect SSH, on Ubuntu 24.04
  3. 3

    Start it

    systemctl enable --now fail2ban && systemctl restart fail2ban
    Terminal: Start it, on Ubuntu 24.04
  4. 4

    Confirm it's watching SSH

    fail2ban-client status sshd
    Terminal: Confirm it's watching SSH, on Ubuntu 24.04

Check It’s Fixed

Run the security report again. This check should now pass.

More Login Attacks Guides

Stop Login Attacks