#!/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