首页 > 其他 > 详细

限制ssh远程登陆

时间:2016-01-29 19:43:17      阅读:212      评论:0      收藏:0      [点我收藏+]
超过十次,就添加到hosts.deny里面去
#!/bin/bash
date=`date +%Y%m%d`
file="/var/log/secure"
max=10
if [[ -f $file ]]
then
        grep Failed $file | awk ‘{print $(NF-3)}‘ | sort -rn | uniq -c | awk ‘{print $2 "=" $1}‘>/shell/ip.txt
fi
for a in `cat /shell/ip.txt`
do
        if [[ `echo $a| awk -F"=" ‘{print $2}‘` -gt $max ]]
        then
                b=`echo $a | awk -F"=" ‘{print $1}‘`
                grep $b /etc/hosts.deny >/dev/null
                if [[ $? != 0 ]]
                then
                echo "sshd:$b" >> /etc/hosts.deny
                fi
        fi
done

限制ssh远程登陆

原文:http://www.cnblogs.com/GXLo/p/5169172.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!