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