Web Hosting & VPS Tips

Unleash Your Server Potential with Expert Insights

Hosting provided by: Cloudways
Free to Try! Up to 40% Off!

Category: VPS Setup

Set Fail2ban to use a specific iptables chain on Ubuntu—install with
apt install fail2ban
then edit /etc/fail2ban/action d/iptables conf with
nano /etc/fail2ban/action.d/iptables.conf
:
actionban = iptables -I fail2ban- 1 -s  -j DROP\nactionunban = iptables -D fail2ban- -s  -j DROP
Update /etc/fail2ban/jail local:
[sshd]\nenabled = true\nport = 22\nfilter = sshd\naction = iptables[name=SSH]\nlogpath = /var/log/auth.log\nmaxretry = 5
Restart with
systemctl restart fail2ban
open SSH with
ufw allow 22
On Hetzner check
iptables -L fail2ban-SSH
—this isolates SSH bans ensuring MySQL and phpMyAdmin uptime

Back to All Tips