brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: fail2ban-regex tests a jail filter on a real log, a security habit

Security
~/tips/tip-security-fail2ban-regex-test-filter

sudo fail2ban-regex /var/log/auth.log sshd

Checks how many log lines a fail2ban filter matches before any ban is created.

A fail2ban filter that matches nothing protects nothing. You can test it on the log you already have.

sudo fail2ban-regex /var/log/auth.log sshd
sudo fail2ban-regex systemd-journal sshd

The tool prints how many lines the filter matched, how many were ignored and some sample matches, without banning anyone. The second form reads the systemd journal, for systems that do not write /var/log/auth.log.

It also accepts a path such as /etc/fail2ban/filter.d/sshd.conf instead of a filter name. Use it every time you write or change a filter, since a typo in the regex fails silently.

Further reading: fail2ban-regex manual page

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link