Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
elearning:workbooks:centos:6:avance:l107 [2020/02/21 07:14] – créée admin | elearning:workbooks:centos:6:avance:l107 [2023/02/15 15:56] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
+ | |||
+ | Version : **2021.01** | ||
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======LRF307 | + | ======LCF306 |
- | =====Présentation===== | + | =====Contenu du Module===== |
- | Quand on parle de NFS, on parle d'**exportation** d'un répertoire | + | * **LCF306 - Gestion |
+ | | ||
+ | | ||
+ | * LAB #1 - John the Ripper | ||
+ | * Surveillance Sécuritaire | ||
+ | * La commande last | ||
+ | * La commande lastlog | ||
+ | * La Commande lastb | ||
+ | * / | ||
+ | * Les Contre-Mesures | ||
+ | * LAB #2 - Renforcer la sécurité des comptes | ||
+ | * LAB #3 - PAM sous RHEL/CentOS 7 | ||
+ | * Bloquer un Compte après N Echecs de Connexion | ||
+ | * Configuration | ||
+ | * LAB #4 - Mise en place du Système de Prévention | ||
+ | * Installation | ||
+ | * Configuration | ||
+ | * Le répertoire | ||
+ | * Le fichier fail2ban.conf | ||
+ | * Le répertoire | ||
+ | * Le répertoire / | ||
+ | * Commandes | ||
+ | * Activer | ||
+ | * Utiliser la Commande Fail2Ban-server | ||
+ | * Ajouter un Prison | ||
- | Le Network File System (NFS) est le protocole de partage de fichiers historique sur des systèmes Unix. Lors de l' | + | =====Le Problématique===== |
- | | + | Un pirate peut utiliser un logiciel de **crackage** pour tenter |
- | * aucun mot de passe n'est demandé lors de la connexion d'un utilisateur à une ressource car le serveur NFS présume que l' | + | |
- | Cependant l' | + | Le principe de ces logiciels est simples - le logiciel utilise des dictionnaires |
- | Il existe actuellement 3 versions de NFS : | + | ====LAB #1 - John the Ripper==== |
- | ^ Version ^ Protocole Utilisé ^ Dépendance ^ | + | ===Installation=== |
- | | **NFSv2** | TCP et UDP | portmap | | + | |
- | | **NFSv3** | TCP et UDP | portmap | | + | |
- | | **NFSv4** | TCP | Aucune - les fonctions de portmap sont incluses dans NFSv4 | | + | |
- | La version utilisée par défaut sous CentOS/Redhat est **NFSv3**. | + | Créez le script suivant dans un terminal de RHEL/CentOS 7 en tant que root : |
- | ====Les Services et Processus du Serveur NFSv3==== | + | < |
+ | [trainee@centos7 ~]$ su - | ||
+ | Password: fenestros | ||
+ | Last login: Mon Apr 23 17:23:14 CEST 2018 on tty1 | ||
+ | [root@centos7 ~]# vi john.sh | ||
+ | [root@centos7 ~]# cat john.sh | ||
+ | # | ||
+ | # Centos 7 John the Ripper Installation | ||
+ | yum -y install wget gpgme | ||
+ | yum -y group install " | ||
+ | cd | ||
+ | wget http:// | ||
+ | wget http:// | ||
+ | wget http:// | ||
+ | gpg --import openwall-signatures.asc | ||
+ | gpg --verify john-1.8.0.tar.xz.sign | ||
+ | tar xvfJ john-1.8.0.tar.xz | ||
+ | cd john-1.8.0/ | ||
+ | make clean linux-x86-64 | ||
+ | cd ../run/ | ||
+ | ./john --test | ||
+ | #password dictionnary download | ||
+ | wget -O - http:// | ||
+ | </ | ||
- | La version NFSv3 utilise les services suivants | + | Rendez-le exécutable |
- | ^ Services ^ Fonction ^ | + | < |
- | | **nfs** | Démarre le service NFS ainsi que les processus RPC pour recevoir et traiter les demandes des clients | | + | [root@centos7 ~]# chmod u+x john.sh |
- | | **nfslock** | Démarre les processus RPC qui permettent aux clients de verrouiller les fichiers sur le serveur | + | </ |
- | | **portmap** | Gestion des réservations des ports pour les services RPC locaux afin que les services RPC distants puissent se connecter | | + | |
- | ===Les Services RPC=== | + | Exécutez le script : |
- | Les services RPC ( //Remote Procedure Calls// ou appel de procédures distantes ) ont été inventé par SUN Microsystem pour faciliter le travail des développeurs | + | < |
+ | [root@centos7 ~]# ./john.sh | ||
+ | </code> | ||
- | Lorsque le client veut faire une requête à un service RPC, il contacte en premier lieu le service **rpcbind** qui assigne un numéro de port au délà du numéro **32768** à un numéro de programme RPC. | + | ===Utilisation=== |
+ | Placez-vous dans le répertoire **/ | ||
- | ====Options d'un Partage NFS==== | + | < |
+ | [root@centos7 ~]# cd john-1.8.0/ | ||
+ | </ | ||
- | Certaines options, appliquées à un partage, modifient le comportement du serveur NFS pour le partage concerné lors de son démarrage | + | Utilisez l' |
- | ^ Option ^ Comportement ^ | + | < |
- | | **ro** | Accès en lecture seule | | + | [root@centos7 run]# ./unshadow /etc/passwd /etc/shadow > mypasswd |
- | | **rw** | Accès en lecture | + | </code> |
- | | **sync** | Ecriture synchrone ( écriture immédiate sur disque ) | | + | |
- | | **async** | Ecriture asynchrone ( écriture sur disque en utilisant une cache ) | | + | |
- | | **root_squash** | Root perd ses prérogatives sur le partage concerné | | + | |
- | | **no_root_squash** | Root garde ses prérogatives sur le partage concerné | | + | |
- | | **no_lock** | Pas de verrous sur les fichiers accédés | | + | |
- | | **all_squash** | Force la mapping de tous les utilisateurs vers l' | + | |
- | | **anonuid** | Fixe l'UID de l' | + | |
- | | **anongid** | Fixe le GID de l' | + | |
- | <WRAP center round important> | + | Consultez le fichier |
- | **Important** : Si plusieurs options sont spécifiées, | + | |
- | </ | + | |
- | ====Commandes de Base==== | + | < |
+ | [root@centos7 run]# cat mypasswd | ||
+ | root: | ||
+ | bin: | ||
+ | daemon: | ||
+ | adm: | ||
+ | lp: | ||
+ | sync: | ||
+ | shutdown: | ||
+ | halt: | ||
+ | mail: | ||
+ | operator: | ||
+ | games: | ||
+ | ftp: | ||
+ | nobody: | ||
+ | avahi-autoipd: | ||
+ | systemd-bus-proxy: | ||
+ | systemd-network: | ||
+ | dbus: | ||
+ | polkitd: | ||
+ | abrt: | ||
+ | usbmuxd: | ||
+ | colord: | ||
+ | libstoragemgmt: | ||
+ | setroubleshoot: | ||
+ | rpc: | ||
+ | rtkit: | ||
+ | chrony: | ||
+ | unbound: | ||
+ | tss: | ||
+ | geoclue: | ||
+ | ntp: | ||
+ | sssd: | ||
+ | rpcuser: | ||
+ | nfsnobody: | ||
+ | pulse: | ||
+ | gdm: | ||
+ | gnome-initial-setup: | ||
+ | avahi: | ||
+ | postfix: | ||
+ | sshd: | ||
+ | tcpdump: | ||
+ | trainee: | ||
+ | vboxadd: | ||
+ | </ | ||
- | Plusieurs commandes permettent de gérer et de s' | + | Lancez **john** pour craquer le fichier **mypasswd** |
- | ^ Commande ^ Comportement ^ | + | < |
- | | **exportfs** | Affiche les partages actifs sur le serveur courant | | + | [root@centos7 run]# ./john mypasswd |
- | | **nfsstat** | Affiche les statistiques de l'activité NFS | | + | Loaded 2 password hashes with 2 different salts (crypt, generic crypt(3) [?/64]) |
- | | **rpcinfo** | Affiche les démons gérés en effectuant une requête RPC sur le serveur courant | | + | Press 'q' or Ctrl-C to abort, almost any other key for status |
- | | **showmount** | Affiche les partages actifs sur un serveur distant | | + | trainee |
- | | **mount** | Permet de monter un partage distant | + | 1g 0:00:00:26 4% 2/3 0.03831g/s 230.1p/s 230.2c/s 230.2C/s Hanson..Kristine |
+ | 1g 0:00:00:27 4% 2/3 0.03658g/s 230.3p/s 230.4c/s 230.4C/s Ruthless..Tanner | ||
+ | 1g 0:00:00:28 4% 2/3 0.03549g/s 230.3p/s 230.3c/s 230.3C/s Bonjour..Blessing | ||
+ | 1g 0:00:00:36 5% 2/3 0.02775g/s 230.6p/s 230.7c/s 230.7C/s dances..olivias | ||
+ | 1g 0:00:01:14 10% 2/3 0.01348g/s 231.2p/s 231.2c/s 231.2C/s rabbitrabbit..dennisdennis | ||
+ | 1g 0:00:01:16 11% 2/3 0.01311g/s 231.1p/s 231.2c/s 231.2C/s grahamgraham..sharkshark | ||
+ | 1g 0:00:01:18 11% 2/3 0.01277g/s 231.2p/s 231.2c/s 231.2C/s reggiereggie..vickivicki | ||
+ | 1g 0:00:01:19 11% 2/3 0.01263g/s 231.1p/s 231.1c/s 231.1C/s javierjavier..melvinmelvin | ||
+ | 1g 0:00:01:20 12% 2/3 0.01244g/s 231.2p/s 231.2c/s 231.2C/s goldengolden..dixondixon | ||
+ | 1g 0:00:01:21 12% 2/3 0.01231g/s 231.2p/s 231.2c/s 231.2C/s obiwanobiwan..bytemebyteme | ||
+ | 1g 0:00:01:22 12% 2/3 0.01218g/s 231.1p/s 231.1c/s 231.1C/s suzysuzy..raeb | ||
+ | 1g 0:00:01:23 12% 2/3 0.01200g/s 231.1p/s 231.2c/s 231.2C/s xilef..ognimalf | ||
+ | 1g 0:00:01:24 12% 2/3 0.01188g/s 231.1p/s 231.2c/s 231.2C/s auhsoj..trebreh | ||
+ | 1g 0:00:01:25 12% 2/3 0.01171g/s 231.2p/s 231.2c/s 231.2C/s namgib..lareneg | ||
+ | 1g 0:00:02:34 21% 2/3 0.006482g/s 231.2p/s 231.2c/s 231.2C/s tinker3..ashraf3 | ||
+ | [q] < | ||
+ | Use the " | ||
+ | Session aborted | ||
+ | </ | ||
- | =====Mise en Place===== | + | Consultez la liste des mots de passe craqués : |
- | ====Configuration du Serveur==== | + | < |
+ | [root@centos7 run]# ./john --show mypasswd | ||
+ | trainee: | ||
- | <WRAP center round important> | + | 1 password hash cracked, 1 left |
- | **Important** : Arrêtez votre VM. Dans la fenêtre de Oracle VM VirtualBox, cliquez sur **Fichier > Paramètres > Réseau** et créez un réseau NAT appelé **NatNetwork**. Dans les paramètres de votre VM, cliquez sur **Réseau** et configurez la Carte 1 en Réseau NAT dans le réseau NatNetwork. Démarrez votre VM. | + | </code> |
- | </WRAP> | + | |
- | Configurez votre interface réseau si ce n'est pas déjà fait : | + | =====Surveillance Sécuritaire===== |
+ | |||
+ | ====La commande last==== | ||
+ | |||
+ | Cette commande indique les dates et heures des connexions des utilisateurs à partir du contenu du fichier **/ | ||
< | < | ||
- | [root@centos7 ~]# nmcli connection add con-name ip_fixe ifname enp0s3 type ethernet ip4 10.0.2.16/ | + | [root@centos7 ~]# last |
- | Connection ' | + | trainee |
- | [root@centos7 ~]# nmcli connection mod ip_fixe ipv4.dns 8.8.8.8 | + | trainee |
- | [root@centos7 ~]# nmcli connection up ip_fixe | + | trainee |
- | Connection successfully activated | + | trainee |
- | [root@centos7 ~]# systemctl restart NetworkManager.service | + | trainee |
+ | reboot | ||
+ | trainee | ||
+ | reboot | ||
+ | trainee | ||
+ | reboot | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | reboot | ||
+ | trainee | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | trainee | ||
+ | (unknown :0 : | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | reboot | ||
+ | trainee | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | (unknown :0 : | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | (unknown :0 : | ||
+ | reboot | ||
+ | trainee | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | (unknown :0 : | ||
+ | reboot | ||
+ | trainee | ||
+ | trainee | ||
+ | trainee | ||
+ | trainee | ||
+ | trainee | ||
+ | (unknown :0 : | ||
+ | reboot | ||
+ | |||
+ | wtmp begins Sat Apr 30 11:43:38 2016 | ||
</ | </ | ||
- | Ajoutez une autre adresse IP pour le NFS : | + | ====La commande lastlog==== |
+ | |||
+ | Cette commande indique les dates et heures de la connexion au système la plus récente des utilisateurs | ||
< | < | ||
- | [root@centos7 ~]# nmcli connection mod ip_fixe | + | [root@centos7 ~]# lastlog |
+ | Username | ||
+ | root | ||
+ | bin **Never logged in** | ||
+ | daemon | ||
+ | adm **Never logged in** | ||
+ | lp | ||
+ | sync | ||
+ | shutdown | ||
+ | halt | ||
+ | mail | ||
+ | operator | ||
+ | games **Never logged in** | ||
+ | ftp **Never logged in** | ||
+ | nobody | ||
+ | avahi-autoipd | ||
+ | systemd-bus-proxy | ||
+ | systemd-network | ||
+ | dbus | ||
+ | polkitd | ||
+ | abrt | ||
+ | usbmuxd | ||
+ | colord | ||
+ | libstoragemgmt | ||
+ | setroubleshoot | ||
+ | rpc **Never logged in** | ||
+ | rtkit **Never logged in** | ||
+ | chrony | ||
+ | unbound | ||
+ | tss **Never logged in** | ||
+ | geoclue | ||
+ | ntp **Never logged in** | ||
+ | sssd | ||
+ | rpcuser | ||
+ | nfsnobody | ||
+ | pulse **Never logged in** | ||
+ | gdm :0 Sat Apr 30 15:22:30 +0200 2016 | ||
+ | gnome-initial-setup | ||
+ | avahi **Never logged in** | ||
+ | postfix | ||
+ | sshd | ||
+ | tcpdump | ||
+ | trainee | ||
+ | vboxadd | ||
+ | snort **Never logged in** | ||
+ | apache | ||
</ | </ | ||
- | Continuez maintenant par la mise en place du service | + | ====La Commande lastb==== |
+ | |||
+ | Cette commande indique les dates et heures des connexions infructueueses des utilisateurs à partir | ||
< | < | ||
- | [root@centos7 ~]# systemctl status nfs.service | + | [root@centos7 ~]# lastb |
- | nfs-server.service - NFS server and services | + | root |
- | | + | |
- | | + | |
- | [root@centos7 ~]# systemctl enable nfs-server.service | + | btmp begins Tue Jun 19 16:37:18 2018 |
- | ln -s '/ | + | |
- | [root@centos7 ~]# systemctl status nfs.service | + | |
- | nfs-server.service - NFS server and services | + | |
- | | + | |
- | | + | |
</ | </ | ||
- | La mise en place d'un partage ponctuel se fait en utilisant la commande **exportfs** en indiquant en argument le répertoire sous la forme de //adresse_ip_du_serveur: | + | ====/var/log/secure==== |
+ | |||
+ | Sous RHEL/CentOS ce fichier contient la journalisation des opérations de gestion des authentifications | ||
< | < | ||
- | [root@centos7 ~]# exportfs | + | [root@centos7 ~]# tail -n 15 / |
- | [root@centos7 | + | Jun 19 22: |
- | [root@centos7 | + | Jun 19 22: |
- | /home/trainee 192.168.1.2 | + | Jun 19 22:04:07 centos7 polkitd[532]: |
+ | Jun 19 23:45:43 centos7 su: pam_unix(su-l: | ||
+ | Jun 19 23:46:13 centos7 su: pam_unix(su-l: | ||
+ | Jun 19 23:48:25 centos7 su: pam_unix(su-l: | ||
+ | Jun 19 23:48:25 centos7 su: pam_unix(su-l: | ||
+ | Jun 19 23:52:22 centos7 su: pam_unix(su-l: | ||
+ | Jun 19 23:52:27 centos7 su: pam_unix(su-l: | ||
+ | Jun 19 23:54:35 centos7 su: pam_unix(su-l: | ||
+ | Jun 19 23:55:33 centos7 su: pam_unix(su-l: | ||
+ | Jun 20 00:01:21 centos7 su: pam_unix(su-l: | ||
+ | Jun 20 00:01:50 centos7 su: pam_unix(su-l: | ||
+ | Jun 20 00:01:53 centos7 su: pam_unix(su-l: | ||
+ | Jun 20 00:02:19 centos7 su: pam_unix(su-l: | ||
</ | </ | ||
- | Démarrez maintenant | + | =====Les Contre-Mesures===== |
+ | |||
+ | Les contre-mesures incluent | ||
+ | |||
+ | ====LAB #2 - Renforcer la sécurité des comptes==== | ||
+ | |||
+ | Passez en revue le fichier | ||
+ | |||
+ | < | ||
+ | root: | ||
+ | bin: | ||
+ | daemon: | ||
+ | adm: | ||
+ | lp: | ||
+ | sync: | ||
+ | shutdown: | ||
+ | halt: | ||
+ | mail: | ||
+ | uucp: | ||
+ | operator: | ||
+ | games: | ||
+ | gopher: | ||
+ | ftp: | ||
+ | nobody: | ||
+ | dbus: | ||
+ | usbmuxd: | ||
+ | avahi-autoipd: | ||
+ | vcsa: | ||
+ | rpc: | ||
+ | rtkit: | ||
+ | abrt: | ||
+ | nscd: | ||
+ | tcpdump: | ||
+ | haldaemon: | ||
+ | apache: | ||
+ | nslcd: | ||
+ | saslauth: | ||
+ | postfix: | ||
+ | avahi: | ||
+ | ntp: | ||
+ | rpcuser: | ||
+ | nfsnobody: | ||
+ | sshd: | ||
+ | pulse: | ||
+ | gdm: | ||
+ | trainee: | ||
+ | vboxadd: | ||
+ | prison: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** : Notez que la valeur de l'UID de root est toujours de 0. Notez cependant que sous RHEL 5 et 6 les UID des utilisateurs normaux commencent à **500** et les UID des comptes système sont inclus entre 1 et 99 par convention. Sous RHEL 7, les UID des utilisateurs normaux commencent à **1000** et les UID des comptes système sont inclus entre 201 et 999. Sous Debian 6, 7 et 8 les UID des utilisateurs normaux commencent à **1000** et les UID des comptes système sont inclus entre 100 et 999 par convention. Sous openSUSE, les UID des utilisateurs normaux commencent à **1000** et les UID des comptes système sont inclus entre 100 et 499. Sous Ubuntu 14.04 les UID des utilisateurs normaux commencent à **1000** et les UID des comptes système sont inclus entre 100 et 999. | ||
+ | </ | ||
+ | |||
+ | Chaque ligne est constituée de 7 champs : | ||
+ | |||
+ | * Le nom d' | ||
+ | * Le mot de passe. Une valeur de **x** dans ce champs indique que le système utilise le fichier **/ | ||
+ | * L'UID. Une valeur unique qui est utilisée pour déterminée les droits aux fichiers et aux répertoires. | ||
+ | * Le GID. Une valeur indiquant le groupe **principal** de l' | ||
+ | * Le nom complet. Ce champs optionnel est aussi appelé **GECOS** | ||
+ | * Le répertoire personnel de l' | ||
+ | * Le shell de l' | ||
+ | |||
+ | Notez d' | ||
+ | |||
+ | < | ||
+ | lp: | ||
+ | </ | ||
+ | |||
+ | Supprimez donc les utilisateurs et groupes inutiles en utilisant des commandes telles: | ||
+ | |||
+ | # userdel -r lp [Entree] | ||
+ | |||
+ | # groupdel lp [Entree] | ||
+ | |||
+ | Pour les utilisateurs restants, utilisez le système de shadowing | ||
< | < | ||
- | [root@centos7 ~]# systemctl start nfs.service | + | [root@centos7 ~]# cat /etc/shadow |
- | [root@centos7 ~]# systemctl status nfs.service | + | root: |
- | nfs-server.service - NFS server and services | + | bin: |
- | Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; | + | daemon: |
- | Active: active (exited) since Thu 2015-10-01 13:18:13 CEST; 4s ago | + | adm: |
- | | + | lp: |
- | | + | sync: |
- | Main PID: 9552 (code=exited, | + | shutdown: |
- | CGroup: /system.slice/ | + | halt: |
+ | mail: | ||
+ | operator: | ||
+ | games: | ||
+ | ftp: | ||
+ | nobody: | ||
+ | avahi-autoipd: | ||
+ | systemd-bus-proxy:!!: | ||
+ | systemd-network: | ||
+ | dbus: | ||
+ | polkitd:!!: | ||
+ | abrt: | ||
+ | usbmuxd: | ||
+ | colord: | ||
+ | libstoragemgmt: | ||
+ | setroubleshoot: | ||
+ | rpc:!!:16779:0:99999:7::: | ||
+ | rtkit:!!: | ||
+ | chrony: | ||
+ | unbound: | ||
+ | tss: | ||
+ | geoclue: | ||
+ | ntp: | ||
+ | sssd: | ||
+ | rpcuser: | ||
+ | nfsnobody: | ||
+ | pulse: | ||
+ | gdm: | ||
+ | gnome-initial-setup: | ||
+ | avahi: | ||
+ | postfix: | ||
+ | sshd: | ||
+ | tcpdump: | ||
+ | trainee: | ||
+ | vboxadd:!!: | ||
+ | </code> | ||
- | Oct 01 13:18:13 centos7.fenestros.loc systemd[1]: Starting NFS server and services... | + | Chaque ligne est constituée de 8 champs |
- | Oct 01 13:18:13 centos7.fenestros.loc systemd[1]: Started NFS server and services. | + | |
+ | * Le nom de l' | ||
+ | * Le mot de passe **crypté** de l' | ||
+ | * **!!** - Le mot de passe n'a pas encore été défini et l' | ||
+ | * ***** - L' | ||
+ | * **vide** - aucun mot de passe sera demandé pour l' | ||
+ | * Le nombre de jours entre le **01/ | ||
+ | * Le nombre de jours que le mot de passe est encore valide. Une valeur de **0** dans ce champs indique sue le mot de passe n' | ||
+ | * Le nombre de jours après lequel le mot de passe doit être changé, | ||
+ | * Le nombre de jours avant la date de modification forcée que l' | ||
+ | * Le nombre de jours après l' | ||
+ | * Le **numéro** du jour après le **01/ | ||
+ | |||
+ | =====LAB #3 - PAM sous RHEL/CentOS 7===== | ||
+ | |||
+ | **PAM** ( //Pluggable Authentification Modules// ou Modules d' | ||
+ | |||
+ | Les fichiers de configuration se trouvent dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 | ||
+ | atd | ||
+ | chfn other smtp.postfix | ||
+ | chsh passwd | ||
+ | config-util | ||
+ | crond | ||
+ | cups pluto sudo-i | ||
+ | fingerprint-auth | ||
+ | fingerprint-auth-ac | ||
+ | gdm-autologin | ||
+ | gdm-fingerprint | ||
+ | gdm-launch-environment | ||
+ | gdm-password | ||
+ | gdm-pin | ||
+ | gdm-smartcard | ||
+ | ksu | ||
+ | liveinst | ||
</ | </ | ||
- | Afin de mettre en place un ou des partages **permanents**, | + | Ces fichiers ont une structure spécifique et sont nommés d' |
< | < | ||
- | /home/trainee 192.168.1.1 | + | [root@centos7 ~]# ls /lib64/security |
- | / | + | pam_access.so |
+ | pam_cap.so | ||
+ | pam_chroot.so | ||
+ | pam_console.so | ||
+ | pam_cracklib.so | ||
+ | pam_debug.so | ||
+ | pam_deny.so | ||
+ | pam_echo.so | ||
+ | pam_env.so | ||
+ | pam_exec.so | ||
+ | pam_faildelay.so | ||
+ | pam_faillock.so | ||
+ | pam_filter | ||
+ | pam_filter.so | ||
+ | pam_fprintd.so | ||
+ | pam_ftp.so | ||
+ | pam_gnome_keyring.so | ||
+ | pam_group.so | ||
+ | pam_issue.so | ||
+ | pam_keyinit.so | ||
+ | pam_krb5 | ||
</ | </ | ||
- | <WRAP center round important> | + | Les modules les plus importants sont : |
- | **Important** | + | |
- | </ | + | |
- | Redémarrez maintenant | + | ^ Module ^ Description ^ |
+ | | pam_access.so | Ce module est utilisé pour interdire l' | ||
+ | | pam_echo.so | Ce module présente le contenu du fichier passé en argument à tout utilisateur lors de sa connexion. | | ||
+ | | pam_limits.so | Ce module implémente les limites des ressources détaillées dans le fichier **/ | ||
+ | | pam_listfile.so | Ce module est utilisé pour consulter un fichier spécifique pour vérifier les authiorisations. Par exemple, | ||
+ | | pam_nologin.so | Ce module interdit les connexions d' | ||
+ | | pam_pwquality.so | Ce module est utilisé pour vérifier la qualité du mot de passe d'un utilisateur | | ||
+ | | pam_securetty.so | Ce module interdit des connexions de root à partir des périphériques tty qui ne sont pas listés dans le fichier **/ | ||
+ | | pam_unix.so | Ce module est utilisé pour vérifier les informations suivantes ; expire, last_change, | ||
+ | |||
+ | Chaque fichier dans /etc/pam.d contient les règles PAM utilisées pendant l' | ||
< | < | ||
- | [root@centos7 ~]# systemctl restart nfs.service | + | [root@centos7 ~]# cat /etc/pam.d/login |
- | [root@centos7 ~]# systemctl status nfs.service | + | #%PAM-1.0 |
- | nfs-server.service | + | auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so |
- | Loaded: loaded (/ | + | auth |
- | Active: active (exited) since Thu 2015-10-01 14:24:50 CEST; 18s ago | + | auth |
- | | + | account |
- | | + | account |
- | | + | password |
- | | + | # pam_selinux.so close should be the first session rule |
- | | + | session |
- | Main PID: 4650 (code=exited, | + | session |
- | CGroup: /system.slice/nfs-server.service | + | session |
+ | # pam_selinux.so open should only be followed by sessions to be executed in the user context | ||
+ | session | ||
+ | session | ||
+ | session | ||
+ | session | ||
+ | session | ||
+ | -session | ||
+ | </code> | ||
- | Oct 01 14:24:50 centos7.fenestros.loc systemd[1]: Starting NFS server and services... | + | La première ligne de ce fichier est un commentaire qui spécifie que le fichier est conforme à la spécification PAM 1.0. |
- | Oct 01 14:24:50 centos7.fenestros.loc exportfs[4649]: exportfs: No options for /home/trainee 192.168.1.1: suggest 192.168.1.1(sync) to avoid warning | + | |
- | Oct 01 14:24:50 centos7.fenestros.loc exportfs[4649]: | + | Ce fichier, tout comme les autres, est ensuite structuré de la façon suivante |
- | Oct 01 14:24:50 centos7.fenestros.loc systemd[1]: Started NFS server and services. | + | |
+ | * Une module par ligne, | ||
+ | * Quatre champs séparés par un espace dans chaque règle dont les trois premières sont obligatoires. | ||
+ | |||
+ | Le **premier champs** est le //**type de module**//. Il en existe quatre | ||
+ | |||
+ | ^ Type ^ Description ^ | ||
+ | | **auth** | Utilisé pour authentifier un utilisateur ou les pré-requis système ( par exemple / | ||
+ | | **account** | Utilisé pour vérifier si l' | ||
+ | | **password** | Utilisé pour vérifier si l' | ||
+ | | **session** | Utilisé pour gérer la session après l' | ||
+ | |||
+ | Le **deuxième champs** est le // | ||
+ | |||
+ | ^ Control-flag ^ Description ^ | ||
+ | | **required** | La réussite de ce module est indispensable. L' | ||
+ | | **requisite** | La réussite de ce module est indispensable. L' | ||
+ | | **sufficient** | La réussite de ce module est suffisant pour authoriser l' | ||
+ | | **optional** | La réussite ou l' | ||
+ | | **include** | Ce control-flag permet d' | ||
+ | |||
+ | Le **troisième champs** stipule le // | ||
+ | |||
+ | Le **quatrième champs** contient éventuellement les **arguments**. | ||
+ | |||
+ | Ouvrez maintenant le fichier **password-auth-ac** | ||
+ | |||
+ | < | ||
+ | [root@centos7 | ||
+ | #%PAM-1.0 | ||
+ | # This file is auto-generated. | ||
+ | # User changes will be destroyed the next time authconfig is run. | ||
+ | auth required | ||
+ | auth sufficient | ||
+ | auth requisite | ||
+ | auth required | ||
+ | |||
+ | account | ||
+ | account | ||
+ | account | ||
+ | account | ||
+ | |||
+ | password | ||
+ | password | ||
+ | password | ||
+ | |||
+ | session | ||
+ | session | ||
+ | -session | ||
+ | session | ||
+ | session | ||
</ | </ | ||
- | Puisque aucune option ne soit spécifiée pour les montages, ceux-ci ont été exportés avec des option par défaut. En utilisant l' | + | Dans ce fichier, si la règle |
+ | |||
+ | ===Bloquer un Compte après N Echecs | ||
+ | |||
+ | Le module PAM **pam_tally.so** permet de bloquer un compte après N échecs de connexion. Afin d' | ||
+ | |||
+ | < | ||
+ | auth required pam_tally.so onerr=fail deny=3 unlock_time=300 | ||
+ | </ | ||
+ | |||
+ | Dans ce cas, après trois tentatives infructueuses | ||
+ | |||
+ | ===Configuration=== | ||
+ | |||
+ | Certains modules de PAM peuvent être configurés grâce aux fichiers présents dans le répertoire **/ | ||
< | < | ||
- | [root@centos7 ~]# exportfs -v | + | [root@centos7 ~]# ls /etc/security |
- | /home/trainee 192.168.1.1(ro, | + | access.conf |
- | /tmp < | + | chroot.conf |
+ | console.apps | ||
+ | console.handlers | ||
</ | </ | ||
- | ====Configuration du Client==== | + | Parmi les fichiers cités on note ceux qui peuvent être utilisés pour configurer les modules suivants : |
- | <WRAP center round important> | + | ^ Fichier/// |
- | **Important** : Arrêtez votre VM. Créez une clône | + | | **access.conf** | Utilisé par le module pam_access.so | |
+ | | **// | ||
+ | | **console.perms** | Utilisé par le module pam_console.so | | ||
+ | | **// | ||
+ | | **group.conf** | Utilisés par le module pam_group.so | | ||
+ | | **limits.conf** | Utilisé par le module pam_limits.so | | ||
+ | | **pam_env.conf** | Utilisé par le module pam_env.so | | ||
+ | | **time.conf** | Utilisé par le module pam_time.so | | ||
+ | |||
+ | <WRAP center round todo 50%> | ||
+ | **A faire** : Passez en revue chacun | ||
</ | </ | ||
- | Re-configurez ensuite l' | + | Dernièrement, |
< | < | ||
- | [root@centos7 ~]# nmcli connection del ip_fixe | + | [root@centos7 ~]# cat / |
+ | #%PAM-1.0 | ||
+ | auth | ||
+ | account | ||
+ | password required | ||
+ | session | ||
+ | </ | ||
- | [root@centos7 ~]# nmcli connection show ip_fixe | + | =====LAB |
- | Error: ip_fixe | + | |
- | [root@centos7 ~]# nmcli connection add con-name ip_fixe ifname enp0s3 type ethernet ip4 10.0.2.17/24 gw4 10.0.2.2 | + | Fail2Ban est un **S**ystème de **P**révention d' |
- | Connection | + | |
- | [root@centos7 ~]# nmcli connection mod ip_fixe ipv4.dns 8.8.8.8 | + | ====Installation==== |
- | [root@centos7 ~]# nmcli connection mod ip_fixe +ipv4.addresses 192.168.1.1/ | + | Sous RHEL/CentOS 7, beaucoup d' |
- | [root@centos7 ~]# nmcli connection up ip_fixe | + | < |
- | Connection successfully activated (D-Bus active path: / | + | [root@centos7 ~]# yum -y install epel-release |
+ | </code> | ||
- | [root@centos7 | + | Ensuite installez Fail2Ban : |
+ | |||
+ | < | ||
+ | [root@centos6 | ||
</ | </ | ||
- | <WRAP center round important > | + | ====Configuration==== |
- | **Important** | + | |
+ | La configuration de Fail2Ban se trouve dans le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# more / | ||
+ | # | ||
+ | # WARNING: heavily refactored in 0.9.0 release. | ||
+ | # customize settings for your setup. | ||
+ | # | ||
+ | # Changes: | ||
+ | # file, but provide customizations in jail.local file, | ||
+ | # or separate .conf files under jail.d/ directory, e.g.: | ||
+ | # | ||
+ | # HOW TO ACTIVATE JAILS: | ||
+ | # | ||
+ | # YOU SHOULD NOT MODIFY THIS FILE. | ||
+ | # | ||
+ | # It will probably be overwritten or improved in a distribution update. | ||
+ | # | ||
+ | # Provide customizations in a jail.local file or a jail.d/ | ||
+ | # For example to change the default bantime for all jails and to enable the | ||
+ | # ssh-iptables jail the following (uncommented) would appear in the .local file. | ||
+ | # See man 5 jail.conf for details. | ||
+ | # | ||
+ | # [DEFAULT] | ||
+ | # bantime = 3600 | ||
+ | # | ||
+ | # [sshd] | ||
+ | # enabled = true | ||
+ | # | ||
+ | # See jail.conf(5) man page for more information | ||
+ | |||
+ | |||
+ | |||
+ | # Comments: use '#' | ||
+ | |||
+ | |||
+ | [INCLUDES] | ||
+ | |||
+ | #before = paths-distro.conf | ||
+ | --More--(4%) | ||
+ | </ | ||
+ | |||
+ | Dans ce fichier se trouvent des sections pour configurer l' | ||
+ | |||
+ | < | ||
+ | ... | ||
+ | [sshd] | ||
+ | |||
+ | port = ssh | ||
+ | logpath = %(sshd_log)s | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Ces sections, appelées des Prisons (//Jails// en anglais), peuvent contenir des directives telles que : | ||
+ | |||
+ | ^ Directive ^ Description ^ | ||
+ | | enabled | Indique si oui (true) ou non (false) le prison est activé. | | ||
+ | | port | Le port à bloquer dans iptables. | | ||
+ | | filter | Le nom du filtre, une expression régulière, | ||
+ | | logpath | Le nom et le chemin du journal à examiner. | | ||
+ | | maxretry | Le nombre maximal de tentatives. | | ||
+ | | action | Spécifie l' | ||
+ | |||
+ | Il n'est pas recommendé de modifier ce fichier afin de ne pas voir ses modifications ecrasées lors de la prochaine mise-à-jour de Fail2Ban. Fail2Ban nous donne la possibilité de créer le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vi / | ||
+ | [root@centos7 ~]# cat / | ||
+ | [DEFAULT] | ||
+ | ignoreip = 127.0.0.1 172.YY+20.0.3 | ||
+ | findtime = 3600 | ||
+ | bantime = 86400 | ||
+ | maxretry = 5 | ||
+ | |||
+ | [sshd] | ||
+ | enabled = true | ||
+ | </ | ||
+ | |||
+ | Il est à noter que les directives dans le fichier **jail.conf** sont surchargées par celles dans les fichiers suivantes et dans l' | ||
+ | |||
+ | * **/ | ||
+ | * **/ | ||
+ | * **/ | ||
+ | |||
+ | <WRAP center round important | ||
+ | **Important** | ||
</ | </ | ||
- | Dans la VM d'origine (serveur) passez SELinux | + | Dans ce fichier, les directives sont donc : |
+ | |||
+ | ^ Directive ^ Description ^ | ||
+ | | ignoreip | Liste des adresses IP, séparées par un **espace**, qui ne sont pas concernées par l' | ||
+ | | findtime | L' | ||
+ | | bantime | La durée de vie des règles, en secondes, inscrites dans le pare-feu | ||
+ | | maxretry | Le nombre maximal de tentatives. La règle sera donc inscrite dans le pare-feu lors de la sixième tentative. | | ||
+ | |||
+ | ===Le répertoire / | ||
+ | |||
+ | Le répertoire **/ | ||
< | < | ||
- | [root@centos7 ~]# getenforce | + | [root@centos7 ~]# ls -l / |
- | Enforcing | + | total 68 |
- | [root@centos7 ~]# setenforce permissive | + | drwxr-xr-x. 2 root root 4096 Jun 8 22:51 action.d |
- | [root@centos7 ~]# systemctl status firewalld.service | + | -rw-r--r--. 1 root root 2328 May 11 2017 fail2ban.conf |
- | firewalld.service | + | drwxr-xr-x. 2 root root 6 Jul 13 2017 fail2ban.d |
- | Loaded: loaded | + | drwxr-xr-x. 3 root root 4096 Jun 8 22:51 filter.d |
- | Active: active | + | -rw-r--r--. 1 root root 21502 Jul 13 2017 jail.conf |
- | Main PID: 479 (firewalld) | + | drwxr-xr-x. 2 root root 30 Jun 8 22:51 jail.d |
- | CGroup: /system.slice/firewalld.service | + | -rw-r--r--. 1 root root 110 Jun 8 22:54 jail.local |
- | └─479 | + | -rw-r--r--. 1 root root 2375 May 11 2017 paths-common.conf |
+ | -rw-r--r--. 1 root root 642 May 11 2017 paths-debian.conf | ||
+ | -rw-r--r--. 1 root root 1070 May 11 2017 paths-fedora.conf | ||
+ | -rw-r--r--. 1 root root 1156 May 11 2017 paths-freebsd.conf | ||
+ | -rw-r--r--. 1 root root 975 May 11 2017 paths-opensuse.conf | ||
+ | -rw-r--r--. 1 root root 290 May 11 2017 paths-osx.conf | ||
+ | </ | ||
+ | |||
+ | ==Le fichier fail2ban.conf== | ||
+ | |||
+ | Ce fichier définit les configurations globales de Fail2Ban, telles le **pidfile**, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# cat / | ||
+ | # Fail2Ban main configuration file | ||
+ | # | ||
+ | # Comments: use '#' | ||
+ | # | ||
+ | # Changes: | ||
+ | # file, but provide customizations in fail2ban.local file, e.g.: | ||
+ | # | ||
+ | # [Definition] | ||
+ | # loglevel = DEBUG | ||
+ | # | ||
+ | |||
+ | [Definition] | ||
+ | |||
+ | # Option: loglevel | ||
+ | # Notes.: Set the log level output. | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # Values: [ LEVEL ] Default: ERROR | ||
+ | # | ||
+ | loglevel = INFO | ||
+ | |||
+ | # Option: logtarget | ||
+ | # Notes.: Set the log target. This could be a file, SYSLOG, STDERR or STDOUT. | ||
+ | # Only one log target can be specified. | ||
+ | # If you change logtarget from the default value and you are | ||
+ | # using logrotate | ||
+ | # | ||
+ | # (e.g. /etc/logrotate.d/fail2ban on Debian systems) | ||
+ | # Values: [ STDOUT | STDERR | SYSLOG | FILE ] Default: STDERR | ||
+ | # | ||
+ | logtarget = /var/log/ | ||
+ | |||
+ | # Option: syslogsocket | ||
+ | # Notes: Set the syslog socket file. Only used when logtarget is SYSLOG | ||
+ | # auto uses platform.system() to determine predefined paths | ||
+ | # Values: [ auto | FILE ] Default: auto | ||
+ | syslogsocket = auto | ||
+ | |||
+ | # Option: socket | ||
+ | # Notes.: Set the socket file. This is used to communicate with the daemon. Do | ||
+ | # not remove this file when Fail2ban runs. It will not be possible to | ||
+ | # | ||
+ | # Values: [ FILE ] Default: /var/ | ||
+ | # | ||
+ | socket = /var/ | ||
+ | |||
+ | # Option: pidfile | ||
+ | # Notes.: Set the PID file. This is used to store the process ID of the | ||
+ | # | ||
+ | # Values: [ FILE ] Default: | ||
+ | # | ||
+ | pidfile = /var/run/ | ||
+ | |||
+ | # Options: dbfile | ||
+ | # Notes.: Set the file for the fail2ban persistent data to be stored. | ||
+ | # A value of ": | ||
+ | # and data is lost when fail2ban is stopped. | ||
+ | # A value of " | ||
+ | # Values: [ None :memory: FILE ] Default: / | ||
+ | dbfile = / | ||
- | Oct 01 14:54:57 centos7.fenestros.loc systemd[1]: Started firewalld - dynamic firewall daemon. | + | # Options: dbpurgeage |
- | [root@centos7 ~]# systemctl stop firewalld.service | + | # Notes.: Sets age at which bans should be purged from the database |
+ | # Values: | ||
+ | dbpurgeage = 86400 | ||
</ | </ | ||
- | A partir de votre client, consultez les répertoire | + | ==Le répertoire |
+ | |||
+ | Ce répertoire contient les fichiers appelés par les directives **filter** dans les sections des prisons | ||
< | < | ||
- | [root@centos7 ~]# showmount | + | [root@centos7 ~]# ls -l / |
- | Export list for 192.168.1.2: | + | total 344 |
- | /tmp * | + | -rw-r--r--. 1 root root 442 May 11 2017 3proxy.conf |
- | / | + | -rw-r--r--. 1 root root 3241 May 11 2017 apache-auth.conf |
+ | -rw-r--r--. 1 root root 2745 May 11 2017 apache-badbots.conf | ||
+ | -rw-r--r--. 1 root root 1273 May 11 2017 apache-botsearch.conf | ||
+ | -rw-r--r--. 1 root root 813 May 11 2017 apache-common.conf | ||
+ | -rw-r--r--. 1 root root 268 May 11 2017 apache-fakegooglebot.conf | ||
+ | -rw-r--r--. 1 root root 487 May 11 2017 apache-modsecurity.conf | ||
+ | -rw-r--r--. 1 root root 596 May 11 2017 apache-nohome.conf | ||
+ | -rw-r--r--. 1 root root 1187 May 11 2017 apache-noscript.conf | ||
+ | -rw-r--r--. 1 root root 2000 May 11 2017 apache-overflows.conf | ||
+ | -rw-r--r--. 1 root root 346 May 11 2017 apache-pass.conf | ||
+ | -rw-r--r--. 1 root root 1014 May 11 2017 apache-shellshock.conf | ||
+ | -rw-r--r--. 1 root root 3418 May 11 2017 assp.conf | ||
+ | -rw-r--r--. 1 root root 2443 May 11 2017 asterisk.conf | ||
+ | -rw-r--r--. 1 root root 520 May 11 2017 botsearch-common.conf | ||
+ | -rw-r--r--. 1 root root 1863 May 11 2017 common.conf | ||
+ | -rw-r--r--. 1 root root 252 May 11 2017 counter-strike.conf | ||
+ | -rw-r--r--. 1 root root 393 May 11 2017 courier-auth.conf | ||
+ | -rw-r--r--. 1 root root 490 May 11 2017 courier-smtp.conf | ||
+ | -rw-r--r--. 1 root root 444 May 11 2017 cyrus-imap.conf | ||
+ | -rw-r--r--. 1 root root 345 May 11 2017 directadmin.conf | ||
+ | -rw-r--r--. 1 root root 1942 May 11 2017 domino-smtp.conf | ||
+ | -rw-r--r--. 1 root root 1875 May 11 2017 dovecot.conf | ||
+ | -rw-r--r--. 1 root root 1696 May 11 2017 dropbear.conf | ||
+ | -rw-r--r--. 1 root root 557 May 11 2017 drupal-auth.conf | ||
+ | -rw-r--r--. 1 root root 1282 May 11 2017 ejabberd-auth.conf | ||
+ | -rw-r--r--. 1 root root 516 May 11 2017 exim-common.conf | ||
+ | -rw-r--r--. 1 root root 1847 May 11 2017 exim.conf | ||
+ | -rw-r--r--. 1 root root 2158 May 11 2017 exim-spam.conf | ||
+ | -rw-r--r--. 1 root root 963 May 11 2017 freeswitch.conf | ||
+ | -rw-r--r--. 1 root root 1209 May 11 2017 froxlor-auth.conf | ||
+ | -rw-r--r--. 1 root root 236 May 11 2017 groupoffice.conf | ||
+ | -rw-r--r--. 1 root root 322 May 11 2017 gssftpd.conf | ||
+ | -rw-r--r--. 1 root root 512 May 11 2017 guacamole.conf | ||
+ | -rw-r--r--. 1 root root 1158 May 11 2017 haproxy-http-auth.conf | ||
+ | -rw-r--r--. 1 root root 404 May 11 2017 horde.conf | ||
+ | drwxr-xr-x. 2 root root 33 Jun 8 22:51 ignorecommands | ||
+ | -rw-r--r--. 1 root root 482 May 11 2017 kerio.conf | ||
+ | -rw-r--r--. 1 root root 323 May 11 2017 lighttpd-auth.conf | ||
+ | -rw-r--r--. 1 root root 2279 May 11 2017 mongodb-auth.conf | ||
+ | -rw-r--r--. 1 root root 773 May 11 2017 monit.conf | ||
+ | -rw-r--r--. 1 root root 652 May 11 2017 murmur.conf | ||
+ | -rw-r--r--. 1 root root 890 May 11 2017 mysqld-auth.conf | ||
+ | -rw-r--r--. 1 root root 400 May 11 2017 nagios.conf | ||
+ | -rw-r--r--. 1 root root 1594 May 11 2017 named-refused.conf | ||
+ | -rw-r--r--. 1 root root 528 May 11 2017 nginx-botsearch.conf | ||
+ | -rw-r--r--. 1 root root 442 May 11 2017 nginx-http-auth.conf | ||
+ | -rw-r--r--. 1 root root 1427 May 11 2017 nginx-limit-req.conf | ||
+ | -rw-r--r--. 1 root root 707 May 11 2017 nsd.conf | ||
+ | -rw-r--r--. 1 root root 459 May 11 2017 openhab.conf | ||
+ | -rw-r--r--. 1 root root 495 May 11 2017 openwebmail.conf | ||
+ | -rw-r--r--. 1 root root 1905 May 11 2017 oracleims.conf | ||
+ | -rw-r--r--. 1 root root 814 May 11 2017 pam-generic.conf | ||
+ | -rw-r--r--. 1 root root 568 May 11 2017 perdition.conf | ||
+ | -rw-r--r--. 1 root root 834 May 11 2017 php-url-fopen.conf | ||
+ | -rw-r--r--. 1 root root 188 May 11 2017 portsentry.conf | ||
+ | -rw-r--r--. 1 root root 1289 May 11 2017 postfix.conf | ||
+ | -rw-r--r--. 1 root root 454 May 11 2017 postfix-rbl.conf | ||
+ | -rw-r--r--. 1 root root 482 May 11 2017 postfix-sasl.conf | ||
+ | -rw-r--r--. 1 root root 1216 May 11 2017 proftpd.conf | ||
+ | -rw-r--r--. 1 root root 2409 May 11 2017 pure-ftpd.conf | ||
+ | -rw-r--r--. 1 root root 795 May 11 2017 qmail.conf | ||
+ | -rw-r--r--. 1 root root 1286 May 11 2017 recidive.conf | ||
+ | -rw-r--r--. 1 root root 1367 May 11 2017 roundcube-auth.conf | ||
+ | -rw-r--r--. 1 root root 821 May 11 2017 screensharingd.conf | ||
+ | -rw-r--r--. 1 root root 517 May 11 2017 selinux-common.conf | ||
+ | -rw-r--r--. 1 root root 570 May 11 2017 selinux-ssh.conf | ||
+ | -rw-r--r--. 1 root root 396 Jul 13 2017 sendmail-auth.conf | ||
+ | -rw-r--r--. 1 root root 2472 Jul 13 2017 sendmail-reject.conf | ||
+ | -rw-r--r--. 1 root root 371 May 11 2017 sieve.conf | ||
+ | -rw-r--r--. 1 root root 706 May 11 2017 slapd.conf | ||
+ | -rw-r--r--. 1 root root 472 May 11 2017 sogo-auth.conf | ||
+ | -rw-r--r--. 1 root root 1094 May 11 2017 solid-pop3d.conf | ||
+ | -rw-r--r--. 1 root root 206 May 11 2017 squid.conf | ||
+ | -rw-r--r--. 1 root root 199 May 11 2017 squirrelmail.conf | ||
+ | -rw-r--r--. 1 root root 186 May 11 2017 sshd-aggressive.conf | ||
+ | -rw-r--r--. 1 root root 4487 May 11 2017 sshd.conf | ||
+ | -rw-r--r--. 1 root root 476 May 11 2017 sshd-ddos.conf | ||
+ | -rw-r--r--. 1 root root 363 May 11 2017 stunnel.conf | ||
+ | -rw-r--r--. 1 root root 649 May 11 2017 suhosin.conf | ||
+ | -rw-r--r--. 1 root root 821 May 11 2017 tine20.conf | ||
+ | -rw-r--r--. 1 root root 374 May 11 2017 uwimap-auth.conf | ||
+ | -rw-r--r--. 1 root root 637 May 11 2017 vsftpd.conf | ||
+ | -rw-r--r--. 1 root root 444 May 11 2017 webmin-auth.conf | ||
+ | -rw-r--r--. 1 root root 520 May 11 2017 wuftpd.conf | ||
+ | -rw-r--r--. 1 root root 503 May 11 2017 xinetd-fail.conf | ||
</ | </ | ||
- | Créez maintenant le répertoire **/nfs** dans le client et montez le partage **192.168.1.2:/ | + | ==Le répertoire |
+ | |||
+ | Ce répertoire contient les fichiers appelés par les directives | ||
< | < | ||
- | [root@centos7 ~]# mkdir /nfs | + | [root@centos7 ~]# ls -l / |
- | [root@centos7 ~]# mount -t nfs 192.168.1.2:/ | + | total 244 |
+ | -rw-r--r--. 1 root root 587 May 11 2017 apf.conf | ||
+ | -rw-r--r--. 1 root root 629 May 11 2017 badips.conf | ||
+ | -rw-r--r--. 1 root root 10620 May 11 2017 badips.py | ||
+ | -rw-r--r--. 2 root root 11791 Jul 13 2017 badips.pyc | ||
+ | -rw-r--r--. 2 root root 11791 Jul 13 2017 badips.pyo | ||
+ | -rw-r--r--. 1 root root 2631 May 11 2017 blocklist_de.conf | ||
+ | -rw-r--r--. 1 root root 1931 May 11 2017 cloudflare.conf | ||
+ | -rw-r--r--. 1 root root 7524 May 11 2017 dshield.conf | ||
+ | -rw-r--r--. 1 root root 1133 May 11 2017 dummy.conf | ||
+ | -rw-r--r--. 1 root root 1538 May 11 2017 firewallcmd-allports.conf | ||
+ | -rw-r--r--. 1 root root 1530 May 11 2017 firewallcmd-ipset.conf | ||
+ | -rw-r--r--. 1 root root 2088 May 11 2017 firewallcmd-multiport.conf | ||
+ | -rw-r--r--. 1 root root 2005 May 11 2017 firewallcmd-new.conf | ||
+ | -rw-r--r--. 1 root root 3223 May 11 2017 firewallcmd-rich-logging.conf | ||
+ | -rw-r--r--. 1 root root 2689 May 11 2017 firewallcmd-rich-rules.conf | ||
+ | -rw-r--r--. 1 root root 1437 May 11 2017 iptables-allports.conf | ||
+ | -rw-r--r--. 1 root root 1868 May 11 2017 iptables-common.conf | ||
+ | -rw-r--r--. 1 root root 1350 May 11 2017 iptables.conf | ||
+ | -rw-r--r--. 1 root root 1828 May 11 2017 iptables-ipset-proto4.conf | ||
+ | -rw-r--r--. 1 root root 1755 May 11 2017 iptables-ipset-proto6-allports.conf | ||
+ | -rw-r--r--. 1 root root 1798 May 11 2017 iptables-ipset-proto6.conf | ||
+ | -rw-r--r--. 1 root root 1431 May 11 2017 iptables-multiport.conf | ||
+ | -rw-r--r--. 1 root root 1910 May 11 2017 iptables-multiport-log.conf | ||
+ | -rw-r--r--. 1 root root 1508 May 11 2017 iptables-new.conf | ||
+ | -rw-r--r--. 1 root root 2282 May 11 2017 iptables-xt_recent-echo.conf | ||
+ | -rw-r--r--. 1 root root 1556 May 11 2017 mail.conf | ||
+ | -rw-r--r--. 1 root root 5233 May 11 2017 mynetwatchman.conf | ||
+ | -rw-r--r--. 1 root root 1493 May 11 2017 netscaler.conf | ||
+ | -rw-r--r--. 1 root root 489 May 11 2017 nftables-allports.conf | ||
+ | -rw-r--r--. 1 root root 3680 May 11 2017 nftables-common.conf | ||
+ | -rw-r--r--. 1 root root 496 May 11 2017 nftables-multiport.conf | ||
+ | -rw-r--r--. 1 root root 1436 May 11 2017 npf.conf | ||
+ | -rw-r--r--. 1 root root 3146 May 11 2017 nsupdate.conf | ||
+ | -rw-r--r--. 1 root root 1023 May 11 2017 route.conf | ||
+ | -rw-r--r--. 1 root root 2762 May 11 2017 sendmail-buffered.conf | ||
+ | -rw-r--r--. 1 root root 1818 May 11 2017 sendmail-common.conf | ||
+ | -rw-r--r--. 1 root root 798 May 11 2017 sendmail.conf | ||
+ | -rw-r--r--. 1 root root 1692 May 11 2017 sendmail-geoip-lines.conf | ||
+ | -rw-r--r--. 1 root root 918 May 11 2017 sendmail-whois.conf | ||
+ | -rw-r--r--. 1 root root 993 May 11 2017 sendmail-whois-ipjailmatches.conf | ||
+ | -rw-r--r--. 1 root root 974 May 11 2017 sendmail-whois-ipmatches.conf | ||
+ | -rw-r--r--. 1 root root 1207 May 11 2017 sendmail-whois-lines.conf | ||
+ | -rw-r--r--. 1 root root 938 May 11 2017 sendmail-whois-matches.conf | ||
+ | -rw-r--r--. 1 root root 2981 May 11 2017 shorewall-ipset-proto6.conf | ||
+ | -rw-r--r--. 1 root root 6021 May 11 2017 smtp.py | ||
+ | -rw-r--r--. 2 root root 5921 Jul 13 2017 smtp.pyc | ||
+ | -rw-r--r--. 2 root root 5921 Jul 13 2017 smtp.pyo | ||
+ | -rw-r--r--. 1 root root 1330 May 11 2017 symbiosis-blacklist-allports.conf | ||
+ | -rw-r--r--. 1 root root 6018 May 11 2017 xarf-login-attack.conf | ||
</ | </ | ||
- | Notez que quand vous essayer | + | ====Commandes==== |
+ | |||
+ | Fail2Ban est constitué | ||
< | < | ||
- | [root@centos7 ~]# cd /nfs | + | [root@centos7 ~]# which fail2ban-client |
- | -bash: cd: /nfs: Permission denied | + | /bin/ |
+ | [root@centos7 ~]# which fail2ban-server | ||
+ | /bin/ | ||
</ | </ | ||
- | <WRAP center round important> | + | L'exécutable |
- | **Important** : Puisque le répertoire **/ | + | |
- | </ | + | |
- | Retournez donc dans le serveur et modifiez le fichier | + | Les options de la commande |
< | < | ||
- | [root@centos7 ~]# cat / | + | [root@centos7 ~]# fail2ban-server --help |
- | /home/trainee 192.168.1.1(async,rw,no_root_squash) | + | Usage: |
- | /tmp * | + | |
+ | Fail2Ban v0.9.7 reads log file that contains password failure report | ||
+ | and bans the corresponding IP addresses using firewall rules. | ||
+ | |||
+ | Only use this command for debugging purpose. Start the server with | ||
+ | fail2ban-client instead. The default behaviour is to start the server | ||
+ | in background. | ||
+ | |||
+ | Options: | ||
+ | -b start in background | ||
+ | -f start in foreground | ||
+ | -s < | ||
+ | -p < | ||
+ | -x force execution of the server | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Report bugs to https:// | ||
</ | </ | ||
- | Redémarrez le service nfs : | + | Les options de la commande **fail2ban-client** sont : |
< | < | ||
- | [root@centos7 ~]# systemctl restart nfs.service | + | [root@centos7 ~]# fail2ban-client --help |
+ | Usage: / | ||
+ | |||
+ | Fail2Ban v0.9.7 reads log file that contains password failure report | ||
+ | and bans the corresponding IP addresses using firewall rules. | ||
+ | |||
+ | Options: | ||
+ | -c < | ||
+ | -s < | ||
+ | -p < | ||
+ | -d dump configuration. For debugging | ||
+ | -i interactive mode | ||
+ | -v increase verbosity | ||
+ | -q decrease verbosity | ||
+ | -x force execution of the server (remove socket file) | ||
+ | -b start server in background (default) | ||
+ | -f start server in foreground (note that the client forks once itself) | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Command: | ||
+ | | ||
+ | start starts the server and the jails | ||
+ | reload | ||
+ | reload < | ||
+ | stop stops all jails and terminate the | ||
+ | | ||
+ | status | ||
+ | | ||
+ | ping tests if the server is alive | ||
+ | help | ||
+ | version | ||
+ | |||
+ | | ||
+ | set loglevel < | ||
+ | | ||
+ | | ||
+ | get loglevel | ||
+ | set logtarget < | ||
+ | Can be STDOUT, STDERR, SYSLOG or a | ||
+ | | ||
+ | get logtarget | ||
+ | set syslogsocket auto|< | ||
+ | auto or < | ||
+ | | ||
+ | get syslogsocket | ||
+ | flushlogs | ||
+ | and reopens it. For log rotation. | ||
+ | |||
+ | | ||
+ | set dbfile < | ||
+ | | ||
+ | " | ||
+ | get dbfile | ||
+ | | ||
+ | set dbpurgeage < | ||
+ | | ||
+ | get dbpurgeage | ||
+ | | ||
+ | |||
+ | JAIL CONTROL | ||
+ | add < | ||
+ | start < | ||
+ | stop < | ||
+ | | ||
+ | status < | ||
+ | with optional flavor or extended | ||
+ | | ||
+ | |||
+ | JAIL CONFIGURATION | ||
+ | set < | ||
+ | set < | ||
+ | < | ||
+ | set < | ||
+ | of < | ||
+ | set < | ||
+ | of < | ||
+ | the ' | ||
+ | ' | ||
+ | set < | ||
+ | list of < | ||
+ | set < | ||
+ | files for < | ||
+ | set < | ||
+ | of < | ||
+ | set < | ||
+ | | ||
+ | set < | ||
+ | < | ||
+ | for < | ||
+ | set < | ||
+ | < | ||
+ | set < | ||
+ | set < | ||
+ | < | ||
+ | to exclude for < | ||
+ | set < | ||
+ | < | ||
+ | set < | ||
+ | for which the filter will look | ||
+ | back for < | ||
+ | set < | ||
+ | a host will be banned for < | ||
+ | set < | ||
+ | | ||
+ | set < | ||
+ | set < | ||
+ | set < | ||
+ | set < | ||
+ | < | ||
+ | for < | ||
+ | set < | ||
+ | | ||
+ | set < | ||
+ | adds a new action named <ACT> for | ||
+ | < | ||
+ | based action, a < | ||
+ | < | ||
+ | else will be a Command Action | ||
+ | set < | ||
+ | < | ||
+ | |||
+ | | ||
+ | set < | ||
+ | sets the start command <CMD> of | ||
+ | the action <ACT> for < | ||
+ | set < | ||
+ | | ||
+ | set < | ||
+ | sets the check command <CMD> of | ||
+ | the action <ACT> for < | ||
+ | set < | ||
+ | | ||
+ | set < | ||
+ | sets the unban command <CMD> of | ||
+ | the action <ACT> for < | ||
+ | set < | ||
+ | sets < | ||
+ | | ||
+ | < | ||
+ | |||
+ | | ||
+ | set < | ||
+ | sets the < | ||
+ | the action <ACT> for < | ||
+ | set < | ||
+ | calls the < | ||
+ | < | ||
+ | for < | ||
+ | |||
+ | JAIL INFORMATION | ||
+ | get < | ||
+ | files for < | ||
+ | get < | ||
+ | for < | ||
+ | get < | ||
+ | < | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | get < | ||
+ | | ||
+ | | ||
+ | get < | ||
+ | | ||
+ | to ignore for < | ||
+ | get < | ||
+ | will look back for failures for | ||
+ | < | ||
+ | get < | ||
+ | < | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | for < | ||
+ | get < | ||
+ | |||
+ | | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | | ||
+ | < | ||
+ | |||
+ | | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | | ||
+ | get < | ||
+ | the action <ACT> for < | ||
+ | |||
+ | Report bugs to https:// | ||
</ | </ | ||
- | Vous noterez que maintenant vous êtes capable de vous positionner | + | ===Activer et Démarrer le Serveur=== |
+ | |||
+ | Pour prendre en compte la configuration | ||
< | < | ||
- | [root@centos7 ~]# cd /nfs | + | [root@centos7 ~]# systemctl status fail2ban |
- | [root@centos7 | + | ● fail2ban.service - Fail2Ban Service |
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | |||
+ | [root@centos7 | ||
+ | |||
+ | Created symlink from / | ||
+ | |||
+ | [root@centos7 ~]# systemctl start fail2ban | ||
+ | |||
+ | [[root@centos7 ~]# ps aux | grep fail2ban-server | ||
+ | root | ||
+ | root | ||
</ | </ | ||
- | =====Surveillance du Serveur===== | + | ===Utiliser la Commande Fail2Ban-server== |
- | ====La Commande rpcinfo==== | + | Pour connaître le status de Fail2Ban-server, |
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fail2ban-client status | ||
+ | Status | ||
+ | |- Number of jail: 1 | ||
+ | `- Jail list: | ||
+ | </ | ||
- | La commande **rpcinfo** permet | + | Il est aussi possible |
< | < | ||
- | [root@centos6 | + | [root@centos7 |
- | program version netid | + | Status for the jail: sshd |
- | 100000 | + | |- Filter |
- | | + | | |- Currently failed: 0 |
- | | + | | |- Total failed: 0 |
- | | + | | `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd |
- | | + | `- Actions |
- | 100000 | + | |- Currently banned: 0 |
- | 100000 | + | |- Total banned: 0 |
- | 100000 | + | `- Banned IP list: |
- | 100000 | + | |
- | 100000 | + | |
- | 100000 | + | |
- | 100000 | + | |
- | 100024 | + | |
- | 100024 | + | |
- | 100024 | + | |
- | | + | |
- | | + | |
- | 100011 | + | |
- | 100011 | + | |
- | 100011 | + | |
- | 100005 | + | |
- | 100005 | + | |
- | 100005 | + | |
- | 100005 | + | |
- | 100005 | + | |
- | | + | |
- | 100005 | + | |
- | 100005 | + | |
- | 100005 | + | |
- | | + | |
- | 100005 | + | |
- | 100005 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100227 | + | |
- | 100227 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100227 | + | |
- | 100227 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100227 | + | |
- | 100227 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100227 | + | |
- | 100227 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
</ | </ | ||
+ | |||
+ | La commande **fail2ban-client** peut être utilisée pour contrôler un prison : | ||
< | < | ||
- | [root@centos7 ~]# rpcinfo | + | [root@centos7 ~]# fail2ban-client stop sshd |
- | program version netid | + | Jail stopped |
- | | + | |
- | | + | [root@centos7 ~]# fail2ban-client status sshd |
- | | + | ERROR NOK: (' |
- | | + | Sorry but the jail ' |
- | | + | |
- | | + | [root@centos7 ~]# fail2ban-client reload |
- | | + | |
- | | + | [root@centos7 ~]# fail2ban-client |
- | 100000 | + | Status for the jail: sshd |
- | 100000 | + | |- Filter |
- | 100000 | + | | |- Currently failed: 0 |
- | 100000 | + | | |- Total failed: 0 |
- | 100024 | + | | `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd |
- | | + | `- Actions |
- | 100024 | + | |- Currently banned: 0 |
- | | + | |- Total banned: 0 |
- | | + | `- Banned IP list: |
- | 100005 | + | |
- | 100005 | + | |
- | 100005 | + | |
- | 100005 | + | |
- | | + | |
- | 100005 | + | |
- | 100005 | + | |
- | 100005 | + | |
- | | + | |
- | 100005 | + | |
- | | + | |
- | | + | |
- | 100003 | + | |
- | 100227 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100227 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100227 | + | |
- | 100003 | + | |
- | 100003 | + | |
- | 100227 | + | |
- | 100021 | + | |
- | | + | |
- | 100021 | + | |
- | | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
- | 100021 | + | |
</ | </ | ||
- | ====La Commande nfsstat==== | + | ===Ajouter un Prison=== |
- | La Commande **nfsstat** permet de vérifier l' | + | Installez maintenant |
< | < | ||
- | [root@centos6 | + | [root@centos7 |
- | Server rpc stats: | + | </ |
- | calls badcalls | + | |
- | 50 | + | |
- | Server nfs v4: | + | Activez et démarrez le service Apache si ce n'est pas déjà lancé |
- | null | + | |
- | 2 4% 48 | + | |
- | Server | + | < |
- | op0-unused | + | [root@centos7 ~]# systemctl status httpd |
- | 0 0% 0 0% 0 0% 5 4% 0 0% 0 0% | + | ● httpd.service - The Apache HTTP Server |
- | create | + | Loaded: loaded (/ |
- | 0 0% 0 0% 0 0% 45 41% 5 4% 0 0% | + | Active: inactive (dead) |
- | lock | + | Docs: man: |
- | 0 0% 0 0% 0 0% 3 2% 0 0% 0 0% | + | man: |
- | open | + | |
- | 0 0% 0 0% 0 0% 0 0% 46 42% 0 | + | [root@centos7 ~]# systemctl enable httpd |
- | putrootfh | + | |
- | 2 1% 0 0% 3 2% 0 0% 0 0% 0 | + | Created symlink from / |
- | renew restorefh | + | |
- | 0 0% 0 0% 0 0% 0 0% 0 0% 0 | + | [root@centos7 ~]# systemctl start httpd |
- | setcltidconf verify | + | |
- | 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% | + | |
- | exchange_id | + | |
- | 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% | + | |
- | getdevlist | + | |
- | 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% | + | |
- | set_ssv | + | |
- | 0 0% 0 0% 0 0% 0 0% 0 | + | |
</ | </ | ||
+ | |||
+ | Modifiez maintenant votre fichier **/ | ||
< | < | ||
- | [root@centos7 ~]# nfsstat | + | [root@centos7 ~]# vi / |
- | Server rpc stats: | + | [root@centos7 ~]# cat / |
- | calls badcalls | + | [DEFAULT] |
- | 34 0 0 0 | + | ignoreip = 127.0.0.1 10.0.2.15 |
+ | findtime = 3600 | ||
+ | bantime = 86400 | ||
+ | maxretry = 5 | ||
- | Server nfs v4: | + | [sshd] |
- | null | + | enabled = true |
- | 1 2% 33 | + | |
- | Server nfs v4 operations: | + | [apache-auth] |
- | op0-unused | + | enabled = true |
- | 0 0% 0 0% 0 0% 5 7% 0 0% 0 | + | </ |
- | create | + | |
- | 0 0% 0 0% 0 0% 22 31% 4 5% 0 | + | Appliquez la nouvelle configuration et constatez le résultat : |
- | lock | + | |
- | 0 0% 0 0% 0 0% 5 7% 0 0% 0 | + | < |
- | open | + | [root@centos7 ~]# fail2ban-client reload |
- | 0 0% 0 0% 0 0% 0 0% 23 33% 0 | + | [root@centos7 ~]# fail2ban-client status |
- | putrootfh | + | Status |
- | 1 1% 0 0% 0 0% 0 0% 0 0% 0 | + | |- Number of jail: 2 |
- | renew restorefh | + | `- Jail list: |
- | 5 7% 0 0% 0 0% 0 0% 0 | + | |
- | setcltidconf verify | + | |
- | 2 2% 0 0% 0 0% 0 0% 0 0% 0 0% | + | |
- | exchange_id | + | |
- | 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% | + | |
- | getdevlist | + | |
- | 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% | + | |
- | set_ssv | + | |
- | 0 0% 0 0% 0 0% 0 0% 0 | + | |
</ | </ | ||
- | ----- | ||
- | < | ||
- | <div align=" | ||
- | Copyright © 2020 Hugh Norris | ||
- | </ | ||
- | </ | ||
----- | ----- | ||
+ | Copyright © 2023 Hugh Norris. |