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

**URL:** <https://forum.yunohost.org/t/fail2ban-impossible-de-demarrer-le-service-failed/7396>\
**Category:** Support\
**Tags:** fail2ban, french\
**Created:** [March 18, 2019, 7:46am UTC](https://forum.yunohost.org/t/fail2ban-impossible-de-demarrer-le-service-failed/7396 "2019-03-18T07:46:34Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![AntoineC](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/a/8dc957/32.png) [@AntoineC](https://forum.yunohost.org/u/AntoineC)\
**Post date:** [April 18, 2019, 2:04pm UTC](https://forum.yunohost.org/t/fail2ban-impossible-de-demarrer-le-service-failed/7396/16 "2019-04-18T14:04:56Z")

</div>

Youpi ! La solution pour relancer fail2ban, quand fail2ban est sur `failed`, était déjà sur le wiki (suffisait de chercher … 😉 ). La voici:

> [@Migration vers Stretch échouée : No such file or directory: '/etc/fail2ban/filter.d/yunohost.conf'](https://forum.yunohost.org/t/migration-vers-stretch-echouee-no-such-file-or-directory-etc-fail2ban-filter-d-yunohost-conf/5138/32):
>
> Une dernière wink wget [http://ftp.fr.debian.org/debian/pool/main/f/fail2ban/fail2ban\_0.9.6-2\_all.deb](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:

```auto
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**

```auto
apt-cache policy fail2ban

```

_Cela retourne:_

```auto
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:**

```auto
systemctl stop fail2ban

```

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

```auto
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**

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

```

_Ce qui retourne_

```auto
--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**

```
dpkg -i --force-confmiss fail2ban_0.9.6-2_all.deb

```

_Cela retourne:_

```auto
(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**

```
dpkg -i --force-confmiss /var/cache/apt/archives/fail2ban*.deb

```

_Cela retourne:_

```auto
(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**

```
yunohost service regen-conf fail2ban --force

```

_Cela retourne_

```auto
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**

```
systemctl restart fail2ban

```

**Vérification du statut de fail2ban**

```
yunohost service status fail2ban

```

_Cela retourne:_

```auto
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

```

Et c’est gagné.

Merci !

---

_[View the full topic](https://forum.yunohost.org/t/fail2ban-impossible-de-demarrer-le-service-failed/7396)._
