linux运维从入门到精通

拒绝恶意用户连接SSH

2017-09-13  本文已影响14人  Aubin
#!/bin/bash  
#  -------------+--------------------   
# * Filename    :       jujue2.sh           
# * Revision    :       2.0             
# * Date        :       2017-09-13
# * Author      :       Aubin           
# * Description :                       
#  -------------+---------------------
#       www.shuaiguoxia.com
#
logfile=./secure
awk '/Failed/{print $(NF-3)}' $logfile | sort -n | uniq -c | while read str ;do
        sum=`echo $str | awk '{print $1}'`
        ip=`echo $str | awk '{print $2}'`
        if [ $sum -gt 20 ]  ;then
                echo "$ip REJECT"
                iptables -A INPUT -s $ip -j REJECT
        fi
done
上一篇下一篇

猜你喜欢

热点阅读