-
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- DietPi-Software | Fail2Ban: Resolved an issue on Debian Bookworm and above, where Dropbear login failures were not detected due to a non-matching default filter. Dropbear runs as native systemd unit since Bookworm, logging to the system journal via STDOUT, which results in a different log entry prefix. The default filter however has not been updated for this. The fix is as well applied to existing Fail2Ban installs, as long as no own override /etc/fail2ban/filter.d/dropbear.local has been created. Many thanks to @ThePlanplan for reporting this issue: #6665
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1710,6 +1710,32 @@ Patch_9_6() | |
# Remove obsolete drop-in config: https://github.com/MichaIng/DietPi/issues/7104 | ||
[[ -f '/etc/systemd/system/[email protected]/dietpi.conf' ]] && G_EXEC rm -R /etc/systemd/system/[email protected]/dietpi.conf | ||
[[ -d '/etc/systemd/system/[email protected]' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /etc/systemd/system/[email protected] | ||
|
||
# Fix filter for STDOUT logging since Bookworm: https://github.com/fail2ban/fail2ban/pull/3597 | ||
if [[ -f '/etc/fail2ban/filter.d/dropbear.conf' && ! -f '/etc/fail2ban/filter.d/dropbear.local' ]] | ||
then | ||
G_DIETPI-NOTIFY 2 'Fixing Dropbear Fail2Ban filter for STDOUT logging since Bookworm: https://github.com/fail2ban/fail2ban/pull/3597' | ||
cat << '_EOF_' > /etc/fail2ban/filter.d/dropbear.local | ||
[INCLUDES] | ||
before = common.conf | ||
[Definition] | ||
_daemon = dropbear | ||
# Fix filter for STDOUT logging since Bookworm: https://github.com/fail2ban/fail2ban/pull/3597 | ||
prefregex = ^%(__prefix_line)s(\[\d+\] [A-Z][a-z]+ \d\d \d\d:\d\d:\d\d )?<F-CONTENT>(?:[Ll]ogin|[Bb]ad|[Ee]xit).+</F-CONTENT>$ | ||
failregex = ^[Ll]ogin attempt for nonexistent user ('.*' )?from <HOST>:\d+$ | ||
^[Bb]ad (PAM )?password attempt for .+ from <HOST>(:\d+)?$ | ||
^[Ee]xit before auth \(user '.+', \d+ fails\): Max auth tries reached - user '.+' from <HOST>:\d+\s*$ | ||
ignoreregex = | ||
# Add journalmatch to enhance performance since Bookworm | ||
journalmatch = _SYSTEMD_UNIT=dropbear.service + _COMM=dropbear | ||
_EOF_ | ||
fi | ||
} | ||
|
||
# v6.35 => v7 migration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters