Skip to content

Instantly share code, notes, and snippets.

@rhenning
Created February 13, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhenning/fccfad3dace3375ac2e6 to your computer and use it in GitHub Desktop.
Save rhenning/fccfad3dace3375ac2e6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
awk '/proftp.*successful/ { print $7 }' /var/log/secure{,.?} \
| cut -f1 -d\[ \
| tr -d '(' \
| sort \
| uniq \
| while read ip ; do
echo flushing $ip from banlist...
for chain in fail2ban-{,REPEAT-}SFTP ; do
/sbin/iptables -D $chain -s $ip -j DROP 2>/dev/null
done
sed -i "/${ip}/d" /etc/fail2ban/ip.blocklist.SFTP
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment