乌班图20.04。尝试为 SSH 配置fail2ban,但fail2ban 未禁止任何 IP
/etc/fail2ban/jail.local
[DEFAULT]
bantime = 10m
ignoreip = 127.0.0.1/8 ##.##.##.##/32 ##.##.##.##/32
findtime = 30m
maxretry = 3
[sshd]
enabled = true
# modes: normal (default), ddos, extra or aggressive (combines all).
#mode = normal
port = ssh,2233
logpath = %(sshd_log)s
backend = %(sshd_backend)s
Run Code Online (Sandbox Code Playgroud)
来自不在ignoreip上的主机进行了20多次错误尝试,但仍然看到这个
fail2ban-client status sshd
Status for the jail: sshd
|- Filter
| |- Currently failed: 0
| |- Total failed: 0
| `- File list: /var/log/auth.log
`- Actions
|- Currently banned: 0
|- Total banned: 0
`- Banned IP list:
Run Code Online (Sandbox Code Playgroud)
跑步
fail2ban-regex --print-all-matched /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf
Run Code Online (Sandbox Code Playgroud)
显示失败的尝试似乎可以被fail2ban看到
| 9 月 7 日 15:59:48 storage sshd[29733]:来自 ##.##.##.## 端口 33260 ssh2 的 root 密码失败
启用调试:fail2ban-client set loglevel DEBUG
我在fail2ban日志上看到的只是这样的条目
2020-09-07 10:45:01,795 fail2ban.filterpyinotif [29945]: DEBUG Event queue size: 16
2020-09-07 10:45:01,795 fail2ban.filterpyinotif [29945]: DEBUG <_RawEvent cookie=0 mask=0x2 name='' wd=2 >
2020-09-07 10:45:07,116 fail2ban.filterpyinotif [29945]: DEBUG Event queue size: 16
2020-09-07 10:45:07,116 fail2ban.filterpyinotif [29945]: DEBUG <_RawEvent cookie=0 mask=0x2 name='' wd=2 >
Run Code Online (Sandbox Code Playgroud)
关于什么可以检查或尝试解决这个问题有什么建议吗?
对于在线程终止几个月后发现此问题的任何人,我在关注大多数文章时在新的 20.04 服务器安装上遇到了同样的问题。
我通过明确设置解决了这个问题:
sshd_backend = systemd
在我的 Jails.local 的 [sshd] 部分。
默认值 (pynotify) 对于该系统来说不正确,或者存在一些更深层次的问题,阻止其按预期运行。