/usr/local/bin/Denyhosts.txt5.&nb..." />

yabo88手机版 - yabo88vip1com登录

帮助中心FAQ

1. #!/bin/bash

2. #Denyhosts SHELL SCRIPT

3. #2013-6-24

4. cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"=" $1;}' >/usr/local/bin/Denyhosts.txt

5. DEFINE="10"

6. for i in `cat /usr/local/bin/Denyhosts.txt`

7. do

8. IP=`echo $i|awk -F= '{print $1}'`

9. NUM=`echo $i|awk -F= '{print $2}'`

10. if [ $NUM -gt $DEFINE ]

11. then

12. grep $IP /etc/hosts.deny >/dev/null

13. if [ $? -gt 0 ];

14. then

15. echo "sshd:$IP" >> /etc/hosts.deny

16. fi

17. fi

18. done

 

1. 添加到定时任务

2. crontab -e

3. 添加定时任务

4. */2 * * * * /usr/local/bin/denyhosts.sh

 

1. 执行启动

2. /sbin/service crond start