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

Use Fail2ban’s multiport action on Ubuntu—install with
apt install fail2ban
then edit /etc/fail2ban/jail local with
nano /etc/fail2ban/jail.local
:
[sshd]\nenabled = true\nport = 22,2222\nfilter = sshd\nlogpath = /var/log/auth.log\nmaxretry = 5\naction = iptables-multiport\nbantime = 3600
Restart with
systemctl restart fail2ban
open ports with
ufw allow 22 && ufw allow 2222
Test with SSH attempts on both ports—check
iptables -L -n
for DROP rules and
fail2ban-client status sshd
for bans On Hetzner this protects multiple SSH instances ensuring MySQL and phpMyAdmin uptime with flexible port monitoring

Back to All Tips