- Install Fail2Ban:
sudo apt install fail2ban
- Create a local configuration file:
sudo touch /etc/fail2ban/jail.local
- Enable SSH protection:
Edit the jail.local file and ensure the [sshd] section is enabled. Check out the Wiki: Fail2Ban and Docker[DEFAULT]
chain = INPUT
[sshd]
enabled = true
enabled = true
port = ssh
logpath = /var/log/auth.log # Adjust for your distribution
maxretry = 5
# chain = INPUT by default
[pam-generic]
enabled = true
# chain = INPUT by default
- Restart Fail2Ban:
sudo systemctl restart fail2ban
- Check active bans:
sudo fail2ban-client status sshd