Nach der Installation von fail2ban zeigt systemctl status fail2ban folgendes an:
# systemctl status fail2ban
× fail2ban.service - Fail2Ban Service Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; preset: enabled) Active: failed (Result: exit-code) since Fri 2024-05-03 10:30:22 CEST; 54s ago Duration: 163ms Docs: man:fail2ban(1) Process: 4115 ExecStart=/usr/bin/fail2ban-server -xf start (code=exited, status=255/EXCEPTION) Main PID: 4115 (code=exited, status=255/EXCEPTION) CPU: 142ms Mai 03 10:30:22 backup systemd[1]: Started fail2ban.service - Fail2Ban Service. Mai 03 10:30:22 backup fail2ban-server[4115]: 2024-05-03 10:30:22,685 fail2ban.configreader [4115]: WARNING 'allowipv6' not defined in 'Definition'. Using default one: 'auto' Mai 03 10:30:22 backup fail2ban-server[4115]: 2024-05-03 10:30:22,698 fail2ban [4115]: ERROR Failed during configuration: Have not found any log file for sshd jail Mai 03 10:30:22 backup fail2ban-server[4115]: 2024-05-03 10:30:22,702 fail2ban [4115]: ERROR Async configuration of server failed Mai 03 10:30:22 backup systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION Mai 03 10:30:22 backup systemd[1]: fail2ban.service: Failed with result 'exit-code'.
Lösung:
1. erstelle die Datei jail.local unter /etc/fail2ban/jail.local und trage folgendes ein:
# nano /etc/fail2ban/jail.local
[sshd]
enabled = true
backend = systemd
2. installiere das Paket python3-systemd:
# apt install python3-systemd
3. starte fail2ban neu:
# systemctl restart fail2ban