Hostxpeed
Login Get Started →
Security

How to Set Up Rate Limiting for SSH

4 min read
26 views
Jun 13, 2026

Method 1: UFW Rate Limiting

sudo ufw limit ssh
sudo ufw reload

Method 2: iptables with Recent Module

sudo iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set --name SSH
sudo iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 --name SSH -j DROP

Method 3: Using Fail2ban

sudo nano /etc/fail2ban/jail.local
[sshd]
maxretry = 3
findtime = 600
bantime = 3600

Was this article helpful?