Secure your server · 5 min
Stop brute-force logins with Fail2ban
Automatically ban IP addresses that keep failing to log in.
Fail2ban watches your logs and blocks IP addresses that fail to log in again and again. It's a good extra layer, even with SSH keys.
Install it
sudo apt install -y fail2banTurn on the SSH protection
Create a local config (it survives updates):
sudo tee /etc/fail2ban/jail.local > /dev/null <<'EOF'
[sshd]
enabled = true
maxretry = 5
findtime = 10m
bantime = 1h
EOF
sudo systemctl enable --now fail2ban
sudo systemctl restart fail2banThis bans an IP for one hour after 5 failed logins within 10 minutes.
Check it's working
sudo fail2ban-client status sshdUnban yourself
If you lock yourself out, sign in through the web console and run (with your IP):
sudo fail2ban-client set sshd unbanip 198.51.100.7Stuck? Contact us or open a support ticket from your panel.