您的位置:首页 > 理论基础 > 计算机网络

shell脚本精华----在10秒内SSH登录失败次数超过3次就使用iptables/tcpwrappers拒绝

2014-07-03 17:15 561 查看
#!/bin/bash

while true
do
badip=$(lastb -i -a | awk '/ssh:notty/ {print $NF}'|sort|uniq -c|awk '($1>3) {print $2}')

for i in $badip
do
iptables -t filter -I INPUT -s $i -p tcp --dport 22 -j DROP
done

: > /var/log/btmp
sleep 10s
done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell脚本