码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2014-07-04 06:22:09      阅读:364      评论:0      收藏:0      [点我收藏+]

标签:shell脚本   ssh登录失败次数超过3次

#!/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脚本精华----在10秒内SSH登录失败次数超过3次就使用iptables/tcpwrappers拒绝,布布扣,bubuko.com

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

标签:shell脚本   ssh登录失败次数超过3次

原文地址:http://9093090.blog.51cto.com/9083090/1434104

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!