-
- #! /bin/bash
- cat /var/log/secure|awk ‘/Failed/{print $(NF-3)}’|sort|uniq -c|awk ‘{print $2"="$1;}’ > /usr/local/bin/black.txt
- for i in `cat /usr/local/bin/black.txt`
- do
- IP=`echo $i |awk -F= ‘{print $1}’`
- NUM=`echo $i|awk -F= ‘{print $2}’`
- result=$(cat /etc/hosts.deny | grep $IP)
- if [[ $NUM -gt 10 ]];then
- if [[ $result = "" ]];then
- echo "sshd: $IP" >> /etc/hosts.deny
- fi
- fi
复制代码
2.
定时任务:10分钟执行一次,crontab -e
-
- */10 * * * * bash /usr/local/bin/secure_ssh.sh
复制代码
———————————————— 版权声明:本文为CSDN博主「跳跳投」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/u013230234/article/details/103375984 |