大网数据广告活动
服务器运维问答

fail2ban not banning IPs on Ubuntu 20.04

· 52CE 我爱测

Ubuntu 20.04. Trying to get fail2ban configured for SSH, but fail2ban not banning any IPs /etc/fail2ban/jail.local [DEFAULT] bantime = 10m ignoreip = 127.0.0.1/8 ##.##.##.##/32 ##.##.##.##/32 findtime = 30m maxretry = 3 [sshd] en…

问题原文

原帖链接 · Francisco1844 · CC BY-SA 4.0

Ubuntu 20.04. Trying to get fail2ban configured for SSH, but fail2ban not banning any IPs

/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

Did 20+ bad attempts from a host not on ignoreip but still see this

 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:   

Running

 fail2ban-regex --print-all-matched /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf

shows the failed attempts seem to be seen by fail2ban
| Sep 7 15:59:48 storage sshd[29733]: Failed password for root from ##.##.##.## port 33260 ssh2

Enabled debug: fail2ban-client set loglevel DEBUG
All I see on the fail2ban log is entries like this

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 >

Any suggestions on what could check or try to solve this issue?

社区高分解答

原帖链接 · Aleks Barbour · CC BY-SA 4.0

For anyone who finds this a few months after the thread died, I hit the same problem on a new 20.04 server install while following most write-ups.

I solved it by explicitly setting:

sshd_backend = systemd

In my [sshd] section of jails.local.

The default (pynotify) was incorrect for that system or had some deeper issue stopping it from functioning as expected.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-09-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。