您的位置:首页 > 运维架构 > Shell

shell防ssh破解脚本

2012-10-25 16:17 453 查看
vim ssh_check.sh
#!/bin/bash
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /var/log/secure | sort | uniq -c|sort -rn   > /opt/zhanglei/ssh_connect_hack.txt
while read line
do
IP=`echo $line |awk  '{print $2}'`
NUM=`echo $line|awk  '{print $1}'`
if [ $NUM -gt 80  ]
then
grep $IP /etc/hosts.deny > /dev/null
if [ $? -ne 0 ]
then
echo "sshd:${IP} " >> /etc/hosts.deny
fi
fi
done</opt/zhanglei/ssh_connect_hack.txt


本文出自 “苏卡卡” 博客,请务必保留此出处http://sukaka.blog.51cto.com/379985/1036560
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: