1 03. Convenience script
Asif Bacchus edited this page 2019-05-21 07:15:30 -06:00

Convenience script

Whether you're uncomfortable typing commands at the prompt, new to Fail2Ban or just want something quick and easy, I've included a script to copy the template files to the right place in a default installation for you. You can also specify a custom directory if your F2B configuration files are in a non-default location. The script backups all files that it changes so you can easily undo changes.

Running the script

The script must be run as ROOT. Otherwise, execution is dead simple. If you are running a default installation of F2B (i.e. your configuration files are in /etc/fail2ban) simply run the script, answer 'yes' when prompted and you're done.

# logged in as root
./f2b-config.sh

# using SUDO
sudo ./f2b-config.sh

If you have a custom intallation of F2B and your configuration files are stored somewhere else, simply provide the path as a parameter: NOTE: The trailing slash doesn't matter, the script will strip it

./f2b-config.sh /path/to/f2b-config/

# example: f2b config stored in opt/fail2ban
./f2b-config.sh /opt/fail2ban/

What the script does

The script simply copies the configuration files in this repo into your F2B configuration directory and provides instructions on restarting F2B to apply the changes. Using this wiki, you can customize the config files and then restart F2B to apply your changes. The script backs up any existing .local and .conf files as .original files in same location.

Reverting changes

If you want to undo the changes made by the script, simply find the changed files and copy the .original file over the corresponding .local or .conf file. For example, undo the changes to jail.local:

cp /etc/fail2ban/jail.local.original /etc/fail2ban/jail.local