解决 Ubuntu 20.04 上 Fail2Ban 启动失败问题:指定 systemd 后端
服务器开启fail2ban失败,通过查看日志发现错误。大致的原因就是fail2ban找不到sshd的日志文件。
·
问题描述
服务器Ubuntu 20.04
开启fail2ban
失败,通过journactltl -f
查看日志发现错误ERROR Failed during configuration: Have not found any log file for sshd jail
。大致的原因就是fail2ban
找不到sshd
的日志文件。
Sep 09 09:52:17 test systemd[1]: Starting Fail2Ban Service...
Sep 09 09:52:17 test systemd[1]: Started Fail2Ban Service.
Sep 09 09:52:17 test fail2ban-server[370030]: 2024-09-09 09:52:17,874 fail2ban [370030]: ERROR Failed during configuration: Have not found any log file for sshd jail
Sep 09 09:52:17 test fail2ban-server[370030]: 2024-09-09 09:52:17,881 fail2ban [370030]: ERROR Async configuration of server failed
Sep 09 09:52:17 test systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION
Sep 09 09:52:17 test systemd[1]: fail2ban.service: Failed with result 'exit-code'.
解决方法(TL;DR:)
执行下边指令:
echo -e "[sshd]\nbackend=systemd\nenabled=true" | sudo tee /etc/fail2ban/jail.local
之后再次重启fail2ban
服务即可!
如果上述方法不行的话,可以试试以下方法(debian 12):
apt install python3-systemd
- include
backend=systemd
in thejail.local
as above- and since Debian 12 is well and truly systemd (by default) now: it should have fail2ban log to systemd journal instead of the logfile. (
logtarget = SYSTEMD-JOURNAL
) in the[DEFAULT]
section.
参考文章
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献2条内容
所有评论(0)