Last active
December 3, 2019 02:54
-
-
Save ckhung/af3c5eab631ee76fc67575d3f0dd0b0c to your computer and use it in GitHub Desktop.
daily cron script to ban (for a longer time) sites repeatedly banned by fail2ban
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 詳見: 「fail2ban: 新手老手 root 網管都要練的金鐘罩」 | |
# http://newtoypia.blogspot.tw/2016/04/fail2ban.html | |
sed -i.bak '/repeated-fail2ban/,+1d' /etc/hosts.deny | |
/etc/fail2ban/repeated-fail2ban.pl -d 7 -g 3 -i 10 >> /etc/hosts.deny | |
cat <<EOF > /etc/apache2/conf.d/repeated-fail2ban | |
<Location /> | |
Order Allow,Deny | |
Allow from all | |
EOF | |
/etc/fail2ban/repeated-fail2ban.pl -f apache2 -d 7 -g 3 -i 10 | sed 's/^/\t/' >> /etc/apache2/conf.d/repeated-fail2ban | |
echo "</Location>" >> /etc/apache2/conf.d/repeated-fail2ban | |
service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment