Raspberry Pi

Fail2ban : impossible de démarrer le service (failed)

Dernière mise à jour : 08/11/2026 à 14h23
La solution pour relancer fail2ban, quand fail2ban est sur 
failed
, était déjà sur le wiki (suffisait de chercher … wink ). La voici:

40 Migration vers Stretch échouée : No such file or directory: '/etc/fail2ban/filter.d/yunohost.conf' Installation

Citation :
Une dernière wink wget http://ftp.fr.debian.org/debian/pool/main/f/fail2ban/fail2ban_0.9.6-2_all.deb dpkg -i --force-confmiss fail2ban_0.9.6-2_all.deb mv /etc/fail2ban /etc/fail2ban.old2 dpkg -i --force-confmiss /var/cache/apt/archives/fail2ban*.deb yunohost service regen-conf fail2ban --force systemctl restart fail2ban yunohost service status fail2ban Peut-être qu’il te faudra mettre un sudo devant certaines commandes. Sinon, peux-tu préciser sur quelle architecture ton YunoHost es…


Les problèmes venaient d’une migration après une mise à jour du serveur, migration dont je n’avais pas pris conscience.

Il faut d’abord terminer la migration (un message sur la messagerie du serveur existe sans doute dans vos emails, en ce sens).

Terminer la migration:

  • Via l’interface “webadmin” de yunohost, aller dans Outils -> Migration
  • En ligne de commande lancer: 
    yunohost tools migrations migrate


Puis, une fois que la migration est terminée, si fail2ban n’est toujours pas actif, et toujours sur 
failed
, alors la solution a consisté à réinstaller le paquet fail2ban
.

Ce qui donne, en connexion ssh sur la raspberry pi, les commandes successives suivantes:

Code BASH :
apt-cache policy fail2ban
systemctl stop fail2ban
mv /etc/fail2ban /etc/fail2ban.old.19.04.18.01
wget http://ftp.fr.debian.org/debian/pool/main/f/fail2ban/fail2ban_0.9.6-2_all.deb
dpkg -i --force-confmiss fail2ban_0.9.6-2_all.deb
dpkg -i --force-confmiss /var/cache/apt/archives/fail2ban*.deb
yunohost service regen-conf fail2ban --force
systemctl restart fail2ban
yunohost service status fail2ban


EN DÉTAILS :

Repérage de la version de fail2ban

Code TEXT :
apt-cache policy fail2ban


Cela retourne:

Code YAML :
fail2ban:
Installed: 0.9.6-2
Candidate: 0.9.6-2
Version table:
*** 0.9.6-2 500
500 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages
100 /var/lib/dpkg/status


Arrêt de fail2ban:

Code TEXT :
systemctl stop fail2ban


On renome le dossier fail2ban pour en faire une copie de sauvegarde si nécessaire

Code BASH :
mv /etc/fail2ban /etc/fail2ban.old.19.04.18.01


Nota: Le fichier se termine ici par .old.19.04.18.01 pour signifier la date, car c’est pratique. Mais il est possible de préférer un nom se terminant simplement en .old.2 ou .old.3, etc …

Téléchargement du paquet fail2ban dans la version repérée précédement

Code RUBY :
wget http://ftp.fr.debian.org/debian/pool/main/f/fail2ban/fail2ban_0.9.6-2_all.deb


Ce qui retourne

Code BASH :
--2019-04-18 13:31:27--  http://ftp.fr.debian.org/debian/pool/main/f/fail2ban/fail2ban_0.9.6-2_all.deb
Resolving ftp.fr.debian.org (ftp.fr.debian.org)... 212.27.32.66, 2a01:e0c:1:1598::2
Connecting to ftp.fr.debian.org (ftp.fr.debian.org)|212.27.32.66|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 287540 (281K) [application/x-debian-package]
Saving to: ‘fail2ban_0.9.6-2_all.deb.1’
 
fail2ban_0.9.6-2_all.deb.1         100%[=============================================================>] 280.80K  1.30MB/s    in 0.2s
 
2019-04-18 13:31:27 (1.30 MB/s) - ‘fail2ban_0.9.6-2_all.deb.1’ saved [287540/287540]


Dépaquetage en forçant les manquants

Code CSS :
dpkg -i --force-confmiss fail2ban_0.9.6-2_all.deb


Cela retourne:

Code TEXT :
(Reading database ... 66744 files and directories currently installed.)
Preparing to unpack fail2ban_0.9.6-2_all.deb ...
Unpacking fail2ban (0.9.6-2) over (0.9.6-2) ...
Setting up fail2ban (0.9.6-2) ...
 
Configuration file '/etc/fail2ban/action.d/apf.conf', does not exist on system.
Installing new config file as you requested.
 
.../... blablabla .../...
 
Configuration file '/etc/fail2ban/paths-debian.conf', does not exist on system.
Installing new config file as you requested.
 
Configuration file '/etc/fail2ban/paths-opensuse.conf', does not exist on system.
Installing new config file as you requested.
Processing triggers for systemd (232-25+deb9u11) ...
Processing triggers for man-db (2.7.6.1-2) ...


Recherche et application des config présentes et archivées

Code CSS :
dpkg -i --force-confmiss /var/cache/apt/archives/fail2ban*.deb


Cela retourne:

Code JAVA :
(Reading database ... 66744 files and directories currently installed.)
Preparing to unpack .../fail2ban_0.9.6-2_all.deb ...
Unpacking fail2ban (0.9.6-2) over (0.9.6-2) ...
Setting up fail2ban (0.9.6-2) ...
Processing triggers for systemd (232-25+deb9u11) ...
Processing triggers for man-db (2.7.6.1-2) ...


Regénération de config de fail2ban

Code CSS :
yunohost service regen-conf fail2ban --force


Cela retourne

Code BASH :
Success! The configuration has been updated for service 'fail2ban'
fail2ban:
applied:
/etc/fail2ban/filter.d/yunohost.conf:
status: force-created
/etc/fail2ban/jail.conf:
status: force-updated
/etc/fail2ban/jail.d/yunohost-jails.conf:
status: force-created
pending: 


Redémarrage de fail2ban

Code NGINX :
systemctl restart fail2ban


Vérification du statut de fail2ban

Code LUA :
yunohost service status fail2ban


Cela retourne:

Code TEXT :
active: active
active_at: 2019-04-18 13:35:03
description: protects against bruteforce and other kind of attacks from the Internet
loaded: enabled
service_file_path: /lib/systemd/system/fail2ban.service
status: running
Cette page a été vue 3 fois