|
|
发表于 2020-5-6 15:59:06
|
显示全部楼层
本帖最后由 Waylon 于 2020-5-6 16:01 编辑
我也用的脚本、、、、错10次的IP禁止再尝试
echo > /root/hosterrorlog
vi secure_ssh.sh
- #!/bin/bash
- cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /root/hosterrorlog
- for i in `cat /root/hosterrorlog`
- do
- IP=`echo $i |awk -F= '{print $1}'`
- NUM=`echo $i|awk -F= '{print $2}'`
- if [ ${#NUM} -gt 1 ]; then
- grep $IP /etc/hosts.deny > /dev/null
- if [ $? -gt 0 ];then
- echo "sshd:$IP:deny" >> /etc/hosts.deny
- fi
- fi
- done
复制代码
chmod u+x secure_ssh.sh
crontab -e
*/5 * * * * /root/secure_ssh.sh
|
|