Quick answer: Install Fail2ban with apt install fail2ban – the SSH jail is usually active immediately on Ubuntu/Debian and bans attackers after 5 failed attempts.
If you landed here: You see thousands of failed login attempts in logs or want additional SSH protection.
Install
apt update && apt install fail2ban -y
systemctl enable --now fail2ban
fail2ban-client status sshd
Basic config
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# bantime = 1h, maxretry = 3 under [DEFAULT]
systemctl restart fail2ban
Related
Products & ordering: Root/VPS server · Manage: NexoraHost · My account · nexorahost.com (Frankfurt · 1 Tbit/s DDoS · 99.9% uptime)
Frequently asked questions (FAQ)
What does Fail2ban do?
Fail2ban monitors log files (e.g. /var/log/auth.log) and automatically bans IPs via firewall after repeated failed attempts.
Is Fail2ban alone enough for SSH security?
No – SSH keys + disabled password login are required. Fail2ban is additional protection.
How long are IPs banned?
Default often 10 minutes (bantime). Adjustable in jail.local – e.g. bantime = 1h, maxretry = 3.