我在Ubuntu 18.04.3上有一个Linux机器,并具有有效的fail2ban配置(就像在所有主机上一样)。
在这种情况下,我设置了一个docker-container,它充当多个用户的sftp服务器-docker-container具有正在运行的rsyslogd
并将登录事件写入/var/log/auth.log
-{{1} }已安装到主机系统上/var/log
。
因此,我在/myapp/log/sftp
中用此配置片段创建了第二个sshd-jail
jail.local
日志文件[myapp-sftp]
filter=sshd
enabled = true
findtime = 1200
maxretry = 2
mode = aggressive
backend = polling
logpath=/myapp/log/sftp/auth.log
绝对存在,并且充满了很多失败的登录尝试-来自我自己和其他人的登录尝试。
但是,监狱永远不会被/myapp/log/sftp/auth.log
中的found
日志条目触发。
我已经重置了fail2ban数据库...并且不知道可能出了什么问题。
我尝试了fail2ban.log
和默认的backend = polling
。
检查pyinotify
表示匹配。
fail2ban-regex
和
# fail2ban-regex /myapp/log/sftp/auth.log /etc/fail2ban/filter.d/sshd.conf
Running tests
=============
Use failregex filter file : sshd, basedir: /etc/fail2ban
Use maxlines : 1
Use datepattern : Default Detectors
Use log file : /myapp/log/sftp/auth.log
Use encoding : UTF-8
Results
=======
Failregex: 268 total
|- #) [# of hits] regular expression
| 3) [64] ^Failed \S+ for invalid user <F-USER>(?P<cond_user>\S+)|(?:(?! from ).)*?</F-USER> from <HOST>(?: port \d+)?(?: on \S+(?: port \d+)?)?(?: ssh\d*)?(?(cond_user): |(?:(?:(?! from ).)*)$)
| 4) [29] ^Failed \b(?!publickey)\S+ for (?P<cond_inv>invalid user )?<F-USER>(?P<cond_user>\S+)|(?(cond_inv)(?:(?! from ).)*?|[^:]+)</F-USER> from <HOST>(?: port \d+)?(?: on \S+(?: port \d+)?)?(?: ssh\d*)?(?(cond_user): |(?:(?:(?! from ).)*)$)
| 6) [64] ^[iI](?:llegal|nvalid) user <F-USER>.*?</F-USER> from <HOST>(?: port \d+)?(?: on \S+(?: port \d+)?)?\s*$
| 21) [111] ^<F-NOFAIL>Connection from</F-NOFAIL> <HOST>
`-
Ignoreregex: 0 total
Date template hits:
|- [# of hits] date format
| [642] {^LN-BEG}(?:DAY )?MON Day %k:Minute:Second(?:\.Microseconds)?(?: ExYear)?
`-
Lines: 642 lines, 0 ignored, 268 matched, 374 missed
[processed in 0.13 sec]
Missed line(s): too many to print. Use --print-all-missed to print all 374 lines
# fail2ban-client status myapp-sftp
Status for the jail: myapp-sftp
|- Filter
| |- Currently failed: 0
| |- Total failed: 0
| `- File list: /myapp/log/sftp/auth.log
`- Actions
|- Currently banned: 0
|- Total banned: 0
`- Banned IP list:
我真的从没收到过预期的# cat /var/log/fail2ban.log | grep myapp
2019-08-21 10:35:33,647 fail2ban.jail [649]: INFO Creating new jail 'wippex-sftp'
2019-08-21 10:35:33,647 fail2ban.jail [649]: INFO Jail 'myapp-sftp' uses pyinotify {}
2019-08-21 10:35:33,664 fail2ban.server [649]: INFO Jail myapp-sftp is not a JournalFilter instance
2019-08-21 10:35:33,665 fail2ban.filter [649]: INFO Added logfile: '/wippex/log/sftp.log' (pos = 0, hash = 287d8cc2e307c5f427aa87c4c649ced889d6bf6a)
2019-08-21 10:35:33,689 fail2ban.jail [649]: INFO Jail 'myapp-sftp' started
条目...也没有禁令。
任何想法都欢迎。
found
来自# fail2ban-server -V
Fail2Ban v0.10.2
Copyright (c) 2004-2008 Cyril Jaquier, 2008- Fail2Ban Contributors
Copyright of modifications held by their respective authors.
/myapp/log/sftp/auth.log
答案 0 :(得分:0)
问题已“解决”。 docker容器仅使用了与主机不同的时区,并且日志文件时间戳不包含时区。
因此fail2ban
假定时间戳记是在其运行环境(在主机上)的同一时区中编写的,并且未解释“旧”日志条目(时差2小时)。
请参见https://github.com/fail2ban/fail2ban/issues/2486
我现在只是将主机时区设置为UTC-但现在将尝试将rsyncd设置为使用时区日期格式