Green YGreck Guides FR
🐧 LinuxIntermediate⏱ 15 min5 steps

Protect SSH with fail2ban

Automatically ban addresses that repeatedly fail to log in.

  1. Installation:
    sudo apt install fail2ban
  2. Create /etc/fail2ban/jail.local so you do not overwrite the original configuration:
    [sshd]
    enabled = true
    maxretry = 5
    findtime = 10m
    bantime = 1h
  3. Enable and start the service:
    sudo systemctl enable --now fail2ban
  4. See the banned addresses:
    sudo fail2ban-client status sshd
  5. Combine with SSH key authentication and a firewall: see the SSH and UFW guides.