我正在使用pureftpd和fail2ban但是没有用。它似乎能够读取日志但是 fail2ban.filter
事件未触发。我调查了很多关于所有可能的问题,我已经做了很多检查,但我不知道为什么这不起作用。我会开始把我的配置,日志和我做的。以前,我必须说我已经在同一个机器上运行ok fail2ban对抗apache和ssh。这个问题只发生在pureftpd:
在我的/etc/fail2ban/jail.local上
[pureftpd]
enabled = true
port = 21
filter = pure-ftpd
logpath = /var/log/messages
backend = polling
maxretry = 5
我改变了几千次(每次更改后重启fail2ban守护进程)。经测试 port = ftp
代替 port = 21
似乎有相同的结果。我试过用 backend = auto
或删除后端语句...相同的结果。
我的 /var/log/messages
正在接收登录ftp的尝试,有些行例如:
Aug 3 08:31:01 88a4998e8b37 pure-ftpd: (?@192.168.0.159) [INFO] New connection from 192.168.0.159
Aug 3 08:31:09 88a4998e8b37 pure-ftpd: (?@192.168.0.159) [WARNING] Authentication failed for user [testinguser]
我的 /etc/fail2ban/filter.d/pure-ftpd.conf
:
[Definition]
__errmsg = Authentication failed for user
failregex = pure-ftpd: \(\?@<HOST>\) \[WARNING\] %(__errmsg)s \[.+\]$
ignoreregex =
我测试了这个 fail2ban-regex /var/log/messages /etc/fail2ban/filter.d/pure-ftpd.conf
并且它返回了很多命中,所以我认为是有效的。
我还将fail2ban置于调试模式,这是用户连接并尝试登录失败时的日志:
2017-08-03 03:31:10,163 fail2ban.filterpoll [4429]: DEBUG /var/log/messages has been modified
2017-08-03 03:31:10,164 fail2ban.datedetector [4429]: DEBUG Matched time template (?:DAY )?MON Day 24hour:Minute:Second(?:\.Microseconds)?(?: Year)?
2017-08-03 03:31:10,165 fail2ban.datedetector [4429]: DEBUG Got time 1470231069.000000 for "'Aug 3 08:31:09'" using template (?:DAY )?MON Day 24hour:Minute:Second(?:\.Microseconds)?(?: Year)?
2017-08-03 03:31:10,165 fail2ban.datedetector [4429]: DEBUG Sorting the template list
2017-08-03 03:31:10,166 fail2ban.datedetector [4429]: DEBUG Winning template: (?:DAY )?MON Day 24hour:Minute:Second(?:\.Microseconds)?(?: Year)? with 2 hits
所以它检测到文件正在变化但是没有触发过滤器。为什么?
与我工作的其他fail2ban服务(例如apache)相比,我在日志中看到了一个区别......当它工作时,日志中会出现这样的行:
2017-08-03 03:43:37,024 fail2ban.filterpoll [4429]: DEBUG /var/log/apache2/error.log has been modified
2017-08-03 03:43:37,025 fail2ban.datedetector [4429]: DEBUG Matched time template (?:DAY )?MON Day 24hour:Minute:Second(?:\.Microseconds)?(?: Year)?
2017-08-03 03:43:37,026 fail2ban.datedetector [4429]: DEBUG Got time 1501767816.000000 for "'Thu Aug 03 08:43:36.224686 2017'" using template (?:DAY )?MON Day 24hour:Minute:Second(?:\.Microseconds)?(?: Year)?
2017-08-03 03:43:37,026 fail2ban.filter [4429]: DEBUG Processing line with time:1501767816.0 and ip:192.168.0.154
2017-08-03 03:43:37,027 fail2ban.filter [4429]: INFO [apache] Found 192.168.0.154
所以,一切看起来都类似于检查文件...它会得到时间,但之后没有触发。可能发生什么?以前有人经历过这个吗?谢谢。
netstat -an
确认一下?