如果在近期的日志中有超过两次登录失败的记录,则拒绝其再次发起连接。
vim /root/bin/filterIPs.sh
#!/bin/sh sed -i '/^sshd:.*/d' /etc/hosts.deny tail -n 500 /var/log/secure | grep -E "sshd:auth.+failure.+rhost" | awk '{print $14}' | awk -F "=" '{print $2}' | sort | uniq -c | awk '{if($1>1)print "sshd:"$2}' >> /etc/hosts.deny
每分钟更新一次
crontab -e
* * * * * /root/bin/filterIPs.sh