Comments on: How to Install Fail2ban to Stop Brute-Force Attacks on Ubuntu 24.04 https://www.tecmint.com/install-fail2ban-ubuntu-24-04/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Mon, 17 Jun 2024 07:14:47 +0000 hourly 1 By: Ravi Saive https://www.tecmint.com/install-fail2ban-ubuntu-24-04/comment-page-1/#comment-2181201 Mon, 17 Jun 2024 07:14:47 +0000 https://www.tecmint.com/?p=56527#comment-2181201 In reply to mirko.

@mirko,

Try these commands to patch and fix the asynchat module issue…

mkdir -m 0755 /usr/lib/python3/dist-packages/fail2ban/compat
sudo mkdir -m 0755 /usr/lib/python3/dist-packages/fail2ban/compat
sudo wget -O /usr/lib/python3/dist-packages/fail2ban/compat/asynchat.py https://github.com/fail2ban/fail2ban/raw/1024452fe1befeb5a0a014386a81ec183cd45bb5/fail2ban/compat/asynchat.py
sudo wget -O /usr/lib/python3/dist-packages/fail2ban/compat/asyncore.py https://github.com/fail2ban/fail2ban/raw/1024452fe1befeb5a0a014386a81ec183cd45bb5/fail2ban/compat/asyncore.py
sudo cp -p /usr/lib/python3/dist-packages/fail2ban/server/asyncserver.py{,.original}
sudo wget -O /usr/lib/python3/dist-packages/fail2ban/server/asyncserver.py https://github.com/fail2ban/fail2ban/raw/1024452fe1befeb5a0a014386a81ec183cd45bb5/fail2ban/server/asyncserver.py
sudo chmod 0644 /usr/lib/python3/dist-packages/fail2ban/{compat/async{hat,ore}.py,server/asyncserver.py}
sudo apt install python3-setuptools
sudo systemctl restart fail2ban
sudo systemctl status fail2ban
]]>
By: mirko https://www.tecmint.com/install-fail2ban-ubuntu-24-04/comment-page-1/#comment-2180352 Fri, 14 Jun 2024 11:01:43 +0000 https://www.tecmint.com/?p=56527#comment-2180352 May I ask which version of Python you are using? Upgrading from Ubuntu 23.10 to 24.04 crashed my previously working fail2ban installation.

The fail2ban version remains unchanged at 1.0.2-3, but Python has been updated from 3.11.6 to 3.12.3. The ‘asynchat‘ module seems to have been removed, causing issues.

I tried to resolve this by downloading the fail2ban version 1.1.0-1 from the Ubuntu source:

wget https://launchpad.net/ubuntu/+source/fail2ban/1.1.0-1/+build/28291332/+files/fail2ban_1.1.0-1_all.deb
sudo dpkg -i fail2ban_1.1.0-1_all.deb

However, I encountered an error stating ‘pyclean‘ was missing, even after installing it manually.

It seems my only options now are to revert to the previous version of Python or wait for a proper fix to be released.

Sorry for the confusion.

]]>