CentOS 7 - Fail2Ban SSH with email notice

Jackbox

Active Member
Joined
Jan 2, 2016
Messages
154
Points
74
Age
25
Ever want email notices with Fail2Ban? Simple.

Code:
yum install epel-release
yum install fail2ban fail2ban-systemd
yum install sendmail
yum install nano
yum update -y selinux-policy*
Now you will want to type:
nano /etc/fail2ban/jail.local
and paste in
Code:
[DEFAULT]
# Ban hosts for one hour:
maxretry = 1
bantime = 60

# Override /etc/fail2ban/jail.d/00-firewalld.conf:
action = %(action_mwl)s
banaction = iptables-multiport


[sshd]
enabled = true
Save the file!

To modify any configurations like the destination email, go ahead and just:
nano /etc/fail2ban/jail.conf

You may also want to change the default maxretry. Bantime is in seconds, 60 seconds is just a minute. If this does not work or you have another distro, share your solution. If you need help, please just ask in a reply.
 

Top