Fail2Ban日志文件中的“找到”了什么?


19

我在/var/log/fail2ban.log中有多个实例,如下所示:

2015-12-27 14:31:21,949 fail2ban.filter         [1020]: INFO    [sshd] Found ###.###.###.###

(其中#代替了多种IP地址。)

该日志条目的确切含义是什么?特别是什么Found表示?

我在这里和http://www.fail2ban.org上搜索了该日志文件的说明。如果我错过了这个问题的明显信息来源,我深表歉意-请指出正确的方向。

这是/etc/fail2ban/filter.d/sshd.config中FailRegex的配置:

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$

在filter.d / sshd.conf中,您的FailRegex是什么?fail2ban.org/wiki/index.php/MANUAL_0_8#Filters
Frank Thomas

(将FailRegex添加到原始帖子中。)
nmax

根据我的日志10:1,ssh是黑客最喜欢的首选。这很可能是其中之一连接到您的系统。我有超过10,000多个IP,仅用于ssh。
cybernard

filter.d / sshd.conf中的任何其他正则表达式模式是否包含单词“ Found”?
Frank Thomas

奇怪的是,字符串'Found'不会出现在sshd.conf或/ etc / fail2ban中的任何文件中。@cybernard我绝对同意;问题在于fail2ban已经禁止ssh尝试,并且系统上已禁用基于密码的ssh(仅基于密钥的ssh)。
nmax

Answers:


17

Found xxx.xxx.xxx.xxx消息表示,fail2ban过滤器在给定的过滤器/ jail日志文件中找到与failregex匹配的行。

例如,如果日志显示

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

第两个Found意思是,在给定的sshd日志(例如/var/log/auth.log)中两次发现IP地址1.2.3.4,并且日志文件中的条目在failregex过滤器中匹配/etc/fail2ban/filter.d/sshd.conf

正如我已配置为在2个ssh-attemtps失败之后禁止使用,第三行显示,在发现这2个出现之后,IP 1.2.3.4已被禁止。

我如何发现的:

在fail2ban的python源代码中(在Debian中是/usr/lib/python3/dist-packages/fail2ban/)执行此操作:

cd /usr/lib/python3/dist-packages/fail2ban/

grep -r "\[%s\] Found" *

在第937行的python文件“ server / filter.py”中,您找到了相应的日志功能:

def processLineAndAdd(self, line, date=None):
  [..]
  logSys.info("[%s] Found %s" % (self.jail.name, ip))
  [..]

我知道自从发布此答复以来已经有很长时间了,但是我还是再次回到了它。如此清晰,完整的回应-谢谢。
nmax
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.