Both tools read your logs and block IPs that keep failing to log in or abuse your services.
fail2ban
Simple and local. Install the package, then create /etc/fail2ban/jail.local:
[DEFAULT] bantime = 1h findtime = 10m maxretry = 5 ignoreip = 127.0.0.1/8 ::1 YOUR.OFFICE.IP [sshd] enabled = true
Then systemctl enable --now fail2ban and check with fail2ban-client status sshd.
CrowdSec
Works the same way, but shares attacker IPs with a community, so known attackers are blocked before they hit you. Install the agent plus a "bouncer" that does the blocking (for example the firewall bouncer):
cscli collections list cscli decisions list
Tips
- Always whitelist your own management IPs, so you can't lock yourself out.
- Add jails or collections for what you actually run: nginx, Postfix, Dovecot, WordPress.
- These tools reduce noise and stop simple attacks. They're no replacement for key-only SSH and up-to-date software.