Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion
  • Search

How to install and configure fail2ban

General questions about VestaCP
Post Reply
  • Print view
Advanced search
4 posts • Page 1 of 1
Milka
Posts: 137
Joined: Tue Feb 11, 2014 2:03 pm

How to install and configure fail2ban
  • Quote

Post by Milka » Tue Feb 11, 2014 2:42 pm

I noticed an entry "How to install and configure fail2ban" in the documentation section (http://vestacp.com/docs/) but there was no documentation (yet) on this subject. Maybe some readers are not familiar with this at all, so I decided to share a simple installation instruction for fail2ban on CentOS to enable you to get some basic protection.

(I'm assuming you know how to use basic commands like insert and :wq to use vi, but google that first if you don't)

1. Connect to your server as root via SSH

Code: Select all

ssh [email protected]
2. Because fail2ban is not available by default, we'll need to download the EPEL repository:

Code: Select all

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
3. Install fail2ban

Code: Select all

yum install fail2ban
4. The default fail2ban config file can be found at /etc/fail2ban/jail.conf. We're creating a copy, and fail2ban will use your configuration changes from that new file.

Code: Select all

cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
5. Now open your new fail2ban configuration file:

Code: Select all

vi /etc/fail2ban/jail.local
Attention: You'll want to enter your personal/office ip address at the ignoreip line, to prevent locking yourself out.
You might also want to change the ban time (how long to block an IP - in seconds), maxretry (number of incorrect login attempts before blocking the IP) and the findtime (if someone attempts and fails the maxretry number of times in the specified findtime they get blocked)


6. Edit the desired sections. For instance:

Code: Select all

[ssh-iptables]
enabled  = true
filter   = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
           sendmail-whois[name=SSH, [email protected], [email protected]]
logpath  = /var/log/secure
maxretry = 5
7. Restart fail2ban.

Code: Select all

service fail2ban restart
8. Now, you probably want to start this on reboot; so enter:

Code: Select all

chkconfig fail2ban on
9. See your rules list:

Code: Select all

iptables -L -n

Note: there's more to do in order to protect your server, but this is a nice place to start... Anyone feel free to add to this post.
Top

skid
VestaCP Team
Posts: 1476
Joined: Wed Apr 06, 2011 11:12 pm

Re: How to install and configure fail2ban
  • Quote

Post by skid » Tue Feb 11, 2014 3:27 pm

This is a great howto, thanks. I'm going to publish on the documentation page.
Top

Milka
Posts: 137
Joined: Tue Feb 11, 2014 2:03 pm

Re: How to install and configure fail2ban
  • Quote

Post by Milka » Tue Feb 11, 2014 3:52 pm

Cool! Will fail2ban be integrated into the VestaCP install?
Top

skid
VestaCP Team
Posts: 1476
Joined: Wed Apr 06, 2011 11:12 pm

Re: How to install and configure fail2ban
  • Quote

Post by skid » Tue Feb 11, 2014 4:05 pm

Not decided yet. It depends on the firewall project which is not started as for now.
Top


Post Reply
  • Print view

4 posts • Page 1 of 1

Return to “General Discussion”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password