#! /bin/bash
#chkconfig:27501
#decription:secure_ssh.sh autostart
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 9 ]];then
if [[ $result = "" ]];then
echo "sshd: $IP:deny" >> /etc/hosts.deny
fi
fi
done
cp /dev/null /tmp/black
exit
SSH 安全脚本
来自
标签:
发表回复