Install and Configure
sudo apt install fail2ban -y
# /etc/fail2ban/jail.local
[DEFAULT]
bantime = 3600
findtime = 600
maxretry = 5
ignoreip = 127.0.0.1/8 YOUR.TRUSTED.IP
[sshd]
enabled = true
port = 22
maxretry = 3
Manage Bans
sudo fail2ban-client status sshd
sudo fail2ban-client set sshd banip 1.2.3.4
sudo fail2ban-client set sshd unbanip 1.2.3.4
💡 ignoreip is CRITICAL: Add your trusted IP before starting Fail2Ban — otherwise you risk banning yourself during configuration.