我试图限制每个时间段的 ssh 登录尝试次数。我该怎么做呢?
我有类似的东西(在海岸墙的规则中)
#ACTION SOURCE DEST PROTO DEST SOURCE
MARK
# PORT PORT(S)
...
Limit:info:SSHA,3,180 net all tcp 22
但似乎不起作用
答案1
您可以使用iptables
限制为每分钟 3 次尝试:
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j DROP
或者使用类似的东西 fail2ban
。 5 次登录尝试失败后,它会按 IP 地址禁止 15 分钟。
答案2
有不同的工具可以执行此操作,例如 denyhosts http://denyhosts.sourceforge.net/