GN Latest News

Configure and fix Fail2ban.

Configure and fix Fail2ban.
Increase Fail2ban security level. (Optional)
Post Reply
Rob Swan
Site Admin
Posts: 76
Joined: Tue Oct 31, 2017 3:03 pm
Location: UK
Contact:

Configure and fix Fail2ban.

Post by Rob Swan »

LETS FIX FAIL2BAN EMAIL
First of, log into your EHCP force web control panel and create a dedicated email account for Fail2ban.

Maybe something like Fail2Ban@MyDomain.com (replacing MyDomain.com with your actual domain name).

Log on to your server using your PC and PuTTY and enter this command.

sudo vi /etc/fail2ban/jail.local

Image

Scroll down until you see the line.

destemail = changeme@gmail.com (should be about line number 34).

position your cursor at the end of the line, press I for insert and change the email address, to your new one.

Image

Yours won’t be Fail2Ban@mydomain.com.

Press enter for a new line, and add these two lines.

sendername = Fail2Ban
sender = Fail2Ban@MyDomain.com

Replacing Fail2Ban@MyDomain.com with your new Fail2ban email address.

Image

Save the changes and exit (Escape :w (enter) :q (enter)).

Now, enter this command.

sudo fail2ban-client restart

Image

Finally, we need to stop Fail2Ban sending us annoying emails every time the service stops and starts.

To do this we just need to create a new config file, which turns these emails off.

Issue this command.

sudo vi /etc/fail2ban/action.d/sendmail-common.local

Image

Press I for insert and paste in this code.

Code: Select all

[Definition]
actionstart =
actionstop  =
Image

Now save the changes and exit the editor (Esc, :w (enter) :q (enter)

Restart Fail2ban to make sure all is ok with this command.

sudo fail2ban-client restart

Now fail2Ban will only send us emails about IP’s that have been banned.

Now, (in PuTTY) you can just type exit (enter) as we are done.

You can delete any emails (from Fail2ban) in your new mailbox that where sent during the setup process.

You may also have some bounced emails in your admin mailbox from Fail2ban, these can be deleted also.
Post Reply