Forked from mitchellkrogza/fail2ban-reset-log-db.sh
Last active
June 19, 2019 22:05
-
-
Save eagle26/e3ba8b81bd651697e9b27e6ef14785ab to your computer and use it in GitHub Desktop.
Bash script to reset Fail2Ban - clears / truncates log file and deletes the sqlite database - stops and restarts service during this process.
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/bash | |
# Bash Script by https://gist.github.com/mitchellkrogza | |
# ************************************************************ | |
# This script clears the log file and database of Fail2Ban | |
# This resets Fail2Ban to a completely clean state | |
# Useful to use after you have finished testing all your jails | |
# and completed your initial setup of Fail2Ban and are now | |
# putting the server into LIVE mode | |
# ************************************************************ | |
# Please Set your log file and sqlite db locations | |
# Locations below are common on Ubuntu and Debian based systems | |
F2Blog="/var/log/fail2ban.log" | |
F2Bdb="/var/lib/fail2ban/fail2ban.sqlite3" | |
# Now let us clean up | |
echo "Stopping Fail2Ban Service" | |
systemctl stop fail2ban | |
echo "Truncating Fail2Ban Log File" | |
truncate -s 0 $F2Blog | |
echo "Deleting Fail2Ban SQLite Database" | |
rm $F2Bdb | |
echo "Restarting Fail2Ban Service" | |
systemctl restart fail2ban | |
echo "All Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made some changes to use systemctl command instead of service command