Skip to content

Instantly share code, notes, and snippets.

View ngugijames's full-sized avatar
🇰🇪
.

James Ngugi ngugijames

🇰🇪
.
View GitHub Profile
@ngugijames
ngugijames / backup_script.sh
Created December 30, 2018 12:57
MySQL backup script
#!/bin/sh
BACKUP=/var/www/html/mysql_backup/backups
cd $BACKUP
sudo mkdir `date '+%d-%m-%Y'`
NOW=$(date +"%d-%m-%Y")
MUSER="user"
MPASS="pass"
MHOST="host"
MYSQL="$(which mysql)"
@ngugijames
ngugijames / gist:bf08e32ffabf164099686a46f59b6e2b
Created August 18, 2020 11:46
Fail2Ban: Unban IP address from all jails
for jail in $(fail2ban-client status | grep 'Jail list:' | sed 's/.*Jail list://' | sed 's/,//g'); do fail2ban-client set $jail unbanip IP_ADDRESS_HERE; done
#Filter:
cd /etc/fail2ban/filter.d
[Definition]
#failregex = <HOST> - - \[(\d{2})/\w{3}/\d{4}:\1:\1:\1 -\d{4}\] "POST /admin/ HTTP/1.1"
#failregex = ^<HOST> - .* "POST /admin/ HTTP/1.1" 499
#failregex = ^<HOST> - .* "(GET|POST|HEAD).*HTTP.*" 404 .*$
#failregex = ^<HOST> - .* "(GET|POST|HEAD) /admin/ HTTP.*" .*$