我安装了 Fail2ban,但我无法启动该服务。每次我都会收到此错误:
systemctl status fail2ban
× fail2ban.service - Fail2Ban Service
Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2023-05-18 12:53:07 CEST; 21s ago
Docs: man:fail2ban(1)
Process: 18283 ExecStart=/usr/bin/fail2ban-server -xf start (code=exited, status=255/EXCEPTION)
Main PID: 18283 (code=exited, status=255/EXCEPTION)
CPU: 105ms
Mai 18 12:53:07 hochzeitsbilder systemd[1]: Started Fail2Ban Service.
Mai 18 12:53:07 hochzeitsbilder fail2ban-server[18283]: 2023-05-18 12:53:07,466 fail2ban >
Mai 18 12:53:07 hochzeitsbilder fail2ban-server[18283]: 2023-05-18 12:53:07,467 fail2ban >
Mai 18 12:53:07 hochzeitsbilder systemd[1]: fail2ban.service: Main process exited, code=exited, statu>
Mai 18 12:53:07 hochzeitsbilder systemd[1]: fail2ban.service: Failed with result 'exit-code'.
lines 1-13/13 (END)
我尝试了所有能找到的方法但仍然没有任何效果。
这也是来自 Fail2ban 的日志文件:
2023-05-18 08:47:24,422 fail2ban.server [661]: INFO -------------------------------------->2023-05-18 08:47:24,422 fail2ban.server [661]: INFO Starting Fail2ban v0.11.2
2023-05-18 08:47:24,423 fail2ban.observer [661]: INFO Observer start...
2023-05-18 08:47:24,445 fail2ban.database [661]: INFO Connected to fail2ban persistent datab>2023-05-18 08:47:24,451 fail2ban.database [661]: WARNING New database created. Version '4'
2023-05-18 08:47:24,451 fail2ban.jail [661]: INFO Creating new jail 'sshd'
2023-05-18 08:47:24,510 fail2ban.jail [661]: INFO Jail 'sshd' uses pyinotify {}
2023-05-18 08:47:24,515 fail2ban.jail [661]: INFO Initiated 'pyinotify' backend
2023-05-18 08:47:24,517 fail2ban.filter [661]: INFO maxLines: 1
2023-05-18 08:47:24,550 fail2ban.filter [661]: INFO maxRetry: 5
2023-05-18 08:47:24,550 fail2ban.filter [661]: INFO findtime: 600
2023-05-18 08:47:24,551 fail2ban.actions [661]: INFO banTime: 600
2023-05-18 08:47:24,551 fail2ban.filter [661]: INFO encoding: UTF-8
2023-05-18 08:47:24,554 fail2ban.filter [661]: INFO Added logfile: '/var/log/auth.log' (po>2023-05-18 08:47:24,562 fail2ban.jail [661]: INFO Jail 'sshd' started
2023-05-18 09:25:53,280 fail2ban.server [661]: INFO Shutdown in progress...
2023-05-18 09:25:53,281 fail2ban.observer [661]: INFO Observer stop ... try to end queue 5 s>2023-05-18 09:25:53,301 fail2ban.observer [661]: INFO Observer stopped, 0 events remaining.
2023-05-18 09:25:53,341 fail2ban.server [661]: INFO Stopping all jails
2023-05-18 09:25:53,342 fail2ban.filter [661]: INFO Removed logfile: '/var/log/auth.log'
2023-05-18 09:25:53,543 fail2ban.actions [661]: NOTICE [sshd] Flush ticket(s) with iptables-m>2023-05-18 09:25:54,544 fail2ban.jail [661]: INFO Jail 'sshd' stopped
2023-05-18 09:25:54,545 fail2ban.database [661]: INFO Connection to database closed.
2023-05-18 09:25:54,545 fail2ban.server [661]: INFO Exiting Fail2ban
你能帮助我吗?
答案1
我在 Ubuntu 22.04 上遇到了同样的问题。
首先,确保您启用的所有 jail 都引用了实际存在的服务。例如,如果您为 Apache 启用了所有 jail,请确保已安装 Apache。
之后,重启机器。重启后,使用 检查 fail2ban 的状态service fail2ban status
。如果未启动,使用 手动启动service fail2ban start
。通过 检查它是否正在运行以及所有 jail 是否已加载fail2ban-client status
。
为了使 fail2ban 在每次重启后自动启动,请使用以下systemctl enable fail2ban
命令,因为在 Ubuntu 22.04 上 fail2ban 默认是禁用的(与早期版本的 Ubuntu 不同):
# systemctl enable fail2ban
Synchronizing state of fail2ban.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable fail2ban
Created symlink /etc/systemd/system/multi-user.target.wants/fail2ban.service → /lib/systemd/system/fail2ban.service.