本文共 430 字,大约阅读时间需要 1 分钟。
#!/bin/sh#Denyhosts shell scriptcat /var/log/secure | awk '/Failed/{print $(NF-3)}' | sort | uniq -c | awk '{print $2"="$1;}' > /root/blacklist.txtDEFINE="5"for i in `cat /root/blacklist.txt`doIP=`echo $i | awk -F= '{print $1}'`NUM=`echo $i | awk -F= '{print $2}'`if [ $NUM -gt $DEFINE ];then grep $IP /etc/hosts.deny > /dev/nullif [ $? -gt 0 ];then echo "sshd:$IP" >> /etc/hosts.denyfifidone* */1 * * * sh /root/shell/deny-ssh.sh
转载地址:http://jqtil.baihongyu.com/