What is 'Found' in Fail2Ban Log File?
I have multiple instances like the following in /var/log/fail2ban.log:
2015-12-27 14:31:21,949 fail2ban.filter [1020]: INFO [sshd] Found ###.###.###.###
(Where # substitutes for a diversity of IP addresses.)
What exactly is the meaning of this log entry? Particularly, what does Found
denote?
I searched here and http://www.fail2ban.org for an explanation of the log file. If I've missed an obvious information source for this question, my apologies - please point me in the right direction.
Here is the config for FailRegex in /etc/fail2ban/filter.d/sshd.config:
failregex = ^%(__prefix_line)s(?:error: PAM: )?[aA]uthentication (?:failure|error) for .* from <HOST>( via \S+)?\s*$
^%(__prefix_line)s(?:error: PAM: )?User not known to the underlying authentication module for .* from <HOST>\s*$
^%(__prefix_line)sFailed \S+ for .*? from <HOST>(?: port \d*)?(?: ssh\d*)?(: (ruser .*|(\S+ ID \S+ \(serial \d+\) CA )?\S+ %(__md5hex)s(,$
^%(__prefix_line)sROOT LOGIN REFUSED.* FROM <HOST>\s*$
^%(__prefix_line)s[iI](?:llegal|nvalid) user .* from <HOST>\s*$
^%(__prefix_line)sUser .+ from <HOST> not allowed because not listed in AllowUsers\s*$
^%(__prefix_line)sUser .+ from <HOST> not allowed because listed in DenyUsers\s*$
^%(__prefix_line)sUser .+ from <HOST> not allowed because not in any group\s*$
^%(__prefix_line)srefused connect from \S+ \(<HOST>\)\s*$
^%(__prefix_line)sReceived disconnect from <HOST>: 3: \S+: Auth fail$
^%(__prefix_line)sUser .+ from <HOST> not allowed because a group is listed in DenyGroups\s*$
^%(__prefix_line)sUser .+ from <HOST> not allowed because none of user's groups are listed in AllowGroups\s*$
^(?P<__prefix>%(__prefix_line)s)User .+ not allowed because account is locked<SKIPLINES>(?P=__prefix)(?:error: )?Received disconnect from$
^(?P<__prefix>%(__prefix_line)s)Disconnecting: Too many authentication failures for .+? \[preauth\]<SKIPLINES>(?P=__prefix)(?:error: )?Co$
^(?P<__prefix>%(__prefix_line)s)Connection from <HOST> port \d+(?: on \S+ port \d+)?<SKIPLINES>(?P=__prefix)Disconnecting: Too many authe$
^%(__prefix_line)spam_unix\(sshd:auth\):\s+authentication failure;\s*logname=\S*\s*uid=\d*\s*euid=\d*\s*tty=\S*\s*ruser=\S*\s*rhost=<HOST$
The Found xxx.xxx.xxx.xxx
message means, that the fail2ban filter found a line that matches failregex in the given filter/jail logfile.
For example if the log shows
2016-03-16 15:35:51,527 fail2ban.filter [1986]: INFO [sshd] Found 1.2.3.4
2016-03-16 15:35:51,817 fail2ban.filter [1986]: INFO [sshd] Found 1.2.3.4
2016-03-16 15:35:52,537 fail2ban.actions [1986]: NOTICE [sshd] Ban 1.2.3.4
The two first Found
mean, that IP address 1.2.3.4 was found 2 times in the given sshd log (e.g. /var/log/auth.log) and that the entry in the logfile matches failregex
in the filter /etc/fail2ban/filter.d/sshd.conf
As I have configured to ban after 2 failed ssh-attemtps, the 3rd line shows, that IP 1.2.3.4 has been banned after those 2 found occurrences.
How I found out about this:
In the python sources of fail2ban (in Debian this is in /usr/lib/python3/dist-packages/fail2ban/
) do this:
cd /usr/lib/python3/dist-packages/fail2ban/
grep -r "\[%s\] Found" *
In the python file "server/filter.py" on line 937 you find the corresponding log function:
def processLineAndAdd(self, line, date=None):
[..]
logSys.info("[%s] Found %s" % (self.jail.name, ip))
[..]