Difference between revisions of "HowToLimitSSHScans"
From PDP/Grid Wiki
Jump to navigationJump to searchm |
m |
||
Line 26: | Line 26: | ||
= Sources = | = Sources = | ||
* [http://www.teaparty.net/technotes/ssh-rate-limiting.html http://www.teaparty.net/technotes/ssh-rate-limiting.html] | * [http://www.teaparty.net/technotes/ssh-rate-limiting.html http://www.teaparty.net/technotes/ssh-rate-limiting.html] | ||
+ | * [http://www.linux-noob.com/forums/index.php/topic/1829-ssh-rate-limit-per-ip-new-method/ http://www.linux-noob.com/forums/index.php/topic/1829-ssh-rate-limit-per-ip-new-method/] |
Latest revision as of 08:03, 21 August 2009
Add this to the very top of the iptables file
# ssh scanning block -A RH-FW-1-INPUT -p tcp -m state --state NEW --dport 22 -m recent --name sshattack --set -A RH-FW-1-INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 30 --hitcount 3 -j LOG --log-prefix "SSH REJECT: " -A RH-FW-1-INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 30 --hitcount 3 -j REJECT --reject-with tcp-reset
so that you get
# Firewall configuration manually crafted for XXX *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :RH-FW-1-INPUT - [0:0] :LOCAL-INPUT - [0:0] -A INPUT -j RH-FW-1-INPUT -A FORWARD -j RH-FW-1-INPUT -A RH-FW-1-INPUT -i lo -j ACCEPT # ssh scanning block -A RH-FW-1-INPUT -p tcp -m state --state NEW --dport 22 -m recent --name sshattack --set -A RH-FW-1-INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 30 --hitcount 3 -j LOG --log-prefix "SSH REJECT: " -A RH-FW-1-INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 30 --hitcount 3 -j REJECT --reject-with tcp-reset # related goes through -A RH-FW-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # services that may go through ...