I just had to install fail2ban on a centOS server with plesk, and thought I write it down as I am going to need it in the future.

Fail2Ban is excellent software as it helps to deter those would brute force attacks on a server.

So first we need to enable the repo called epel, so as the root user:

Then in the text editor (I use nano) of your choice edit the repo to disable it (we only want to enable it to download any packages from it, this adds security):

and change


Now we are going to install fail2ban, we will also need the whois program so fail2ban can query ip whois database:

now we have our packages installed, we want to copy the config file and use the copy so we have a backup if we mess things up:

OK we are ready to edit our config file so:

I normally leave the the defaults in place. So find the place where ‘[ssh-iptables]’ is located in the file.
This is already turned on but you will need to alter a few options. A quick review of the basic options are:

  • enabled : Whether to turn the filter on or off.
  • filter : Which filter to use located in ‘/etc/fail2ban/filter.d’.
  • action : The action to take located in ‘/etc/fail2ban/action.d’.
  • logpath : Where the log to scan is located.
  • maxretry : the number of times a login attempt can be made before a ban.
  • bantime : How long the ban will last in seconds.
  • findtime : The ban is reset if no match is found within “findtime” seconds.

So with that in mind here are some rules for ssh, postfix, courier-imap and proftpd. Change ‘yourdomain.com’ to your actual server domain and ‘user@yourdomain.com’ to your email address you want the whois data sent to.

Now edit the following filters:


/etc/fail2ban/filter.d/proftpd.conf. Repalce the failregex with:

Because Plesk doesn’t log failed auth attempts in proftpd, we have to make it do so.

/etc/proftpd.conf add:

create ‘proftpd’ directory in ‘/var/log’

Create a file in ‘/etc/logrotate.d’

and put this in it:

Now restart fail2ban and proftpd:

Now you should have a more secure server. Enjoy!

This post is taken from my old site and was originally posted on