Topic: [SOLVED] fail2ban not working
Hi!
In my server(Recently installation, currently in test) fail2ban is configured but it don't ban IPs with failed attempts.
My configuration is the default after the installation.
If I run:
fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf
I get the correct output:
Running tests
=============
Use regex file : /etc/fail2ban/filter.d/sshd.conf
Use log file : /var/log/auth.log
Results
=======
Failregex
|- Regular expressions:
| [1] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*(?:error: PAM: )?Authentication failure for .* from <HOST>\s*$
| [2] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*(?:error: PAM: )?User not known to the underlying authentication module for .* from <HOST>\s*$
| [3] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*Failed (?:password|publickey) for .* from <HOST>(?: port \d*)?(?: ssh\d*)?$
| [4] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*ROOT LOGIN REFUSED.* FROM <HOST>\s*$
| [5] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*[iI](?:llegal|nvalid) user .* from <HOST>\s*$
| [6] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*User .+ from <HOST> not allowed because not listed in AllowUsers$
| [7] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*authentication failure; logname=\S* uid=\S* euid=\S* tty=\S* ruser=\S* rhost=<HOST>(?:\s+user=.*)?\s*$
| [8] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*refused connect from \S+ \(<HOST>\)\s*$
| [9] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*Address <HOST> .* POSSIBLE BREAK-IN ATTEMPT!*\s*$
| [10] ^\s*(?:\S+ )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*User .+ from <HOST> not allowed because none of user's groups are listed in AllowGroups\s*$
|
`- Number of matches:
[1] 0 match(es)
[2] 0 match(es)
[3] 6 match(es)
[4] 0 match(es)
[5] 40 match(es)
[6] 0 match(es)
[7] 0 match(es)
[8] 0 match(es)
[9] 0 match(es)
[10] 0 match(es)
Ignoreregex
|- Regular expressions:
|
`- Number of matches:
Summary
=======
Addresses found:
[1]
[2]
[3]
XXXXXXXXXXXXXX (Tue Jul 27 02:46:01 2010)
... several times the same line ...
XXXXXXXXXXXXXX (Tue Jul 27 02:49:51 2010)
[4]
[5]
XXXXXXXXXXXXXX (Tue Jul 27 02:17:17 2010)
... several times the same line ...
XXXXXXXXXXXXXX (Tue Jul 27 03:17:16 2010)
[6]
[7]
[8]
[9]
[10]
Date template hits:
16096 hit(s): MONTH Day Hour:Minute:Second
0 hit(s): WEEKDAY MONTH Day Hour:Minute:Second Year
0 hit(s): WEEKDAY MONTH Day Hour:Minute:Second
0 hit(s): Year/Month/Day Hour:Minute:Second
0 hit(s): Day/Month/Year Hour:Minute:Second
0 hit(s): Day/Month/Year Hour:Minute:Second
0 hit(s): Day/MONTH/Year:Hour:Minute:Second
0 hit(s): Month/Day/Year:Hour:Minute:Second
0 hit(s): Year-Month-Day Hour:Minute:Second
0 hit(s): Day-MONTH-Year Hour:Minute:Second[.Millisecond]
0 hit(s): Day-Month-Year Hour:Minute:Second
0 hit(s): TAI64N
0 hit(s): Epoch
0 hit(s): ISO 8601
0 hit(s): Hour:Minute:Second
0 hit(s): <Month/Day/Year@Hour:Minute:Second>
Success, the total number of match is 46
However, look at the above section 'Running tests' which could contain important
information.
This tell that fail2ban has found 46 entries... but if I run the client in interactive mode and ask for status:
[10:28:09] root@hostname:[/etc/fail2ban]:fail2ban-client -i
Fail2Ban v0.8.4-SVN reads log file that contains password failure report
and bans the corresponding IP addresses using firewall rules.
fail2ban> status ssh-iredmail
Status for the jail: ssh-iredmail
|- filter
| |- File list: /var/log/auth.log
| |- Currently failed: 0
| `- Total failed: 0
`- action
|- Currently banned: 0
| `- IP list:
`- Total banned: 0
fail2ban>
I'm using Ubuntu 11.04 in amazon EC2 host.
My log from syslog
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Creating new jail 'ssh-iredmail'
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Jail 'ssh-iredmail' uses poller
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Added logfile = /var/log/auth.log
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Set maxRetry = 5
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Set findtime = 36000
Jul 27 03:19:34 ec2 fail2ban.actions: INFO Set banTime = 600
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Creating new jail 'roundcube-iredmail'
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Jail 'roundcube-iredmail' uses poller
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Added logfile = /var/log/mail.log
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Set maxRetry = 5
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Set findtime = 3600
Jul 27 03:19:34 ec2 fail2ban.actions: INFO Set banTime = 3600
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Creating new jail 'dovecot-iredmail'
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Jail 'dovecot-iredmail' uses poller
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Added logfile = /var/log/dovecot.log
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Set maxRetry = 5
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Set findtime = 300
Jul 27 03:19:34 ec2 fail2ban.actions: INFO Set banTime = 3600
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Creating new jail 'postfix-iredmail'
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Jail 'postfix-iredmail' uses poller
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Added logfile = /var/log/mail.log
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Set maxRetry = 5
Jul 27 03:19:34 ec2 fail2ban.filter : INFO Set findtime = 600
Jul 27 03:19:34 ec2 fail2ban.actions: INFO Set banTime = 3600
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Jail 'ssh-iredmail' started
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Jail 'roundcube-iredmail' started
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Jail 'dovecot-iredmail' started
Jul 27 03:19:34 ec2 fail2ban.jail : INFO Jail 'postfix-iredmail' started
Thanks!
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.