Fail2Ban fails on Ubuntu 24.04 LTS

This post is more of a knowledge share. I recently tried self-hosting my Frappe instance on a VM with Ubuntu 24.04 LTS for a sandbox instance.

Noticed that the fail2ban service was failing and tried looking for why this was happening.

Found this posted answer in fail2ban’s github. [BR]: ERROR No module named 'asynchat' on Ubuntu 24.04 · Issue #3755 · fail2ban/fail2ban · GitHub

This is related to an unsupported Python version in the new Ubuntu 24.04. Fail2ban already updated their package to be compatible with the used version of Python, but updates can take a while to reach stable within the main ubuntu repo.
Workaround is to manually install the latest fail2ban version. Commands to past into your terminal (stolen from Ubuntu 24.04 and Fail2Ban Issue Fix / Workaround - AIRIX.NET)

cd /tmp/
# 1) download deb package and signature:
wget -O fail2ban.deb
wget -O fail2ban.deb.asc

# 2) check signature (if you want to be sure file is unmodified):
gpg --verify fail2ban.deb.asc fail2ban.deb

# 3) view details of the package:
dpkg -I fail2ban.deb

# 4) to ensure the upgrade run gentler (protocol of previous version may be incompatible), stop fail2ban before install:
# using service:
sudo service fail2ban stop

# 5a) install package using dpkg (standalone package, don't regard dependencies):
sudo dpkg -i fail2ban.deb
# if the package introduces some "broken" dependencies (I don't think so in case of fail2ban which has few dependencies),
# to fix the unmet dependency issue, run this:
sudo apt -f install
1 Like