« Installation de Fail2ban » : différence entre les versions

De www.yakakliker.org
Aucun résumé des modifications
 
(15 versions intermédiaires par le même utilisateur non affichées)
Ligne 50 : Ligne 50 :
</syntaxhighlight><syntaxhighlight lang="bash" line="1">
</syntaxhighlight><syntaxhighlight lang="bash" line="1">
banaction = ufw
banaction = ufw
banaction_allports = ufw
</syntaxhighlight>
</syntaxhighlight>


Ligne 61 : Ligne 63 :
findtime = 1d
findtime = 1d
</syntaxhighlight>
</syntaxhighlight>
===== Paramétrage du service SSHD =====
<syntaxhighlight lang="bash" line="1">
[sshd]
enabled  = true
port    = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s
</syntaxhighlight>
===== Paramétrage du service Apache2 =====
<syntaxhighlight lang="bash" line="1">
[apache-badbots]
enabled  = true
port    = http,https
filter  = apache-badbots
logpath  = /var/log/apache*/*error.log
maxretry = 2
[apache-overflows]
enabled  = true
port    = http,https
filter  = apache-overflows
logpath  = /var/log/apache*/*error.log
maxretry = 2
[apache-nohome]
enabled  = true
port    = http,https
filter  = apache-nohome
logpath  = /var/log/apache*/*error.log
maxretry = 2


</syntaxhighlight>


==== Redémarrage du service Fail2ban pour prendre en compte les paramètres ====
==== Redémarrage du service Fail2ban pour prendre en compte les paramètres ====
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo systemctl restart fail2ban
sudo systemctl restart fail2ban
</syntaxhighlight>ou<syntaxhighlight lang="bash">
sudo systemctl reload fail2ban
</syntaxhighlight>
</syntaxhighlight>


Ligne 74 : Ligne 115 :
[[Fichier:Capture d’écran du 2024-03-15 14-02-37.png|centré|vignette|1179x1179px]]<syntaxhighlight lang="bash">
[[Fichier:Capture d’écran du 2024-03-15 14-02-37.png|centré|vignette|1179x1179px]]<syntaxhighlight lang="bash">
sudo tail -f /var/log/fail2ban.log
sudo tail -f /var/log/fail2ban.log
</syntaxhighlight>
[[Fichier:Capture d’écran du 2024-03-18 15-12-10.png|vignette|1101x1101px|néant]]<syntaxhighlight lang="bash">
sudo fail2ban-client banned
</syntaxhighlight>
[[Fichier:Capture d’écran du 2024-03-28 15-29-50.png|néant|vignette|1097x1097px]]
==== Statut de UFW ====
<syntaxhighlight lang="bash">
sudo ufw status verbose
</syntaxhighlight>
</syntaxhighlight>


Ligne 81 : Ligne 131 :


* https://www.digitalocean.com/community/tutorials/how-to-protect-ssh-with-fail2ban-on-ubuntu-22-04
* https://www.digitalocean.com/community/tutorials/how-to-protect-ssh-with-fail2ban-on-ubuntu-22-04
 
* https://scalastic.io/ufw-fail2ban-nginx/
* https://fr.linux-console.net/?p=5262
* https://www.digitalocean.com/community/tutorials/how-to-protect-an-apache-server-with-fail2ban-on-ubuntu-14-04
* https://k-lfa.info/securiser-fail2ban/
* https://www.yakakliker.org/images/html/banIP.sh
[[Catégorie:Fail2ban]]
[[Catégorie:Fail2ban]]
[[Catégorie:Linux]]
[[Catégorie:Linux]]
Ligne 87 : Ligne 141 :
[[Catégorie:Tutoriel]]
[[Catégorie:Tutoriel]]
[[Catégorie:IPS]]
[[Catégorie:IPS]]
‎<html>
<script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
<script>
  kofiWidgetOverlay.draw('yakakliker', {
    'type': 'floating-chat',
    'floating-chat.donateButton.text': 'Café',
    'floating-chat.donateButton.background-color': '#00b9fe',
    'floating-chat.donateButton.text-color': '#fff'
  });
</script>
‎</html>
‎<html>
<a href="https://www.compteurdevisite.com" title="compteur web gratuit sans pub"><img src="https://counter6.optistats.ovh/private/compteurdevisite.php?c=b4epghealnwlf7wuq7gn3ygll9aywrfx" border="0" title="compteur web gratuit sans pub" alt="compteur web gratuit sans pub"></a>
‎</html>

Dernière version du 17 février 2025 à 14:32

Fail2ban est un IPS (Intrusion Prevention Software) open source.

Il permet de sécuriser les serveurs Linux contre les tentatives de connexions malveillantes et les attaques DDOS.

Fail2ban réduit les tentatives de connexion malveillantes en bloquant les adresses IP sources.

Installation & configuration du firewall UFW

sudo apt install ufw -y

Autorisation du SSH dans UFW

sudo ufw allow ssh

Activation du service UFW

sudo ufw enable


Installation & configuration de Fail2ban

sudo apt install fail2ban -y

Activation du service Fail2ban

sudo systemctl enable fail2ban
sudo systemctl start fail2ban

Configuration du service Fail2ban

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local
Ajout des IP LAN qui ne seront pas surveillées par Fail2ban
ignoreip = 127.0.0.1/8 ::1 192.168.1.0/24 192.168.10.20
Paramétrage du bannissement des IP
bantime  = 30d
findtime  = 10m
maxretry = 5
banaction = ufw
banaction_allports = ufw
Paramétrage de la récidive
[recidive]
enabled = true
logpath  = /var/log/fail2ban.log
banaction = %(banaction_allports)s
bantime  = 90d
findtime = 1d
Paramétrage du service SSHD
[sshd]
enabled  = true
port     = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s
Paramétrage du service Apache2
[apache-badbots]

enabled  = true
port     = http,https
filter   = apache-badbots
logpath  = /var/log/apache*/*error.log
maxretry = 2

[apache-overflows]

enabled  = true
port     = http,https
filter   = apache-overflows
logpath  = /var/log/apache*/*error.log
maxretry = 2

[apache-nohome]

enabled  = true
port     = http,https
filter   = apache-nohome
logpath  = /var/log/apache*/*error.log
maxretry = 2

Redémarrage du service Fail2ban pour prendre en compte les paramètres

sudo systemctl restart fail2ban

ou

sudo systemctl reload fail2ban

Vérification du service Fail2ban

sudo fail2ban-client status sshd
sudo tail -f /var/log/fail2ban.log
sudo fail2ban-client banned

Statut de UFW

sudo ufw status verbose

Liens

compteur web gratuit sans pub