Table des matières

OPENVPN

Version : 2026.01

Dernière mise-à-jour : 2025/12/04 09:31

LDF408 - Cryptologie

Contenu du module

Le Problématique

Le sniffing des paquets de données est possible sur un réseau utilisant une technologie de diffusion tel un réseau Ethernet. En effet certains protocoles ne cryptent pas les données avant de les envoyer dont :

Un sniffeur est un logiciel qui captent les paquets circulant sur un réseau de type diffusion afin de les analyser. Le logiciel les plus utilisé est :

LAB #1 - Utilisation de tcpdump

Le logiciel tcpdump sert à écouter le réseau en interceptant les paquets.

1.1 - Utilisation

Installez tcpdump :

root@debian12:~# apt install tcpdump
L'option -i

Pour écouter sur une interface spécifique, utilisez l'option -i :

root@debian12:~# tcpdump -i ens18 -c 10
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on ens18, link-type EN10MB (Ethernet), snapshot length 262144 bytes
17:29:37.411395 IP 10.0.2.46.ssh > 10.0.2.1.42252: Flags [P.], seq 119569853:119570041, ack 3811519177, win 501, options [nop,nop,TS val 3553055771 ecr 1647876767], length 188
17:29:37.411528 IP 10.0.2.1.42252 > 10.0.2.46.ssh: Flags [.], ack 188, win 10591, options [nop,nop,TS val 1647876791 ecr 3553055771], length 0
17:29:37.493738 IP 10.0.2.46.36881 > dns.google.domain: 55995+ PTR? 1.2.0.10.in-addr.arpa. (39)
17:29:37.495598 IP dns.google.domain > 10.0.2.46.36881: 55995 NXDomain 0/0/0 (39)
17:29:37.495837 IP 10.0.2.46.33051 > dns.google.domain: 43187+ PTR? 46.2.0.10.in-addr.arpa. (40)
17:29:37.497464 IP dns.google.domain > 10.0.2.46.33051: 43187 NXDomain 0/0/0 (40)
17:29:37.497758 IP 10.0.2.46.ssh > 10.0.2.1.42252: Flags [P.], seq 188:536, ack 1, win 501, options [nop,nop,TS val 3553055857 ecr 1647876791], length 348
17:29:37.497891 IP 10.0.2.1.42252 > 10.0.2.46.ssh: Flags [.], ack 536, win 10591, options [nop,nop,TS val 1647876877 ecr 3553055857], length 0
17:29:37.597097 IP 10.0.2.46.52033 > dns.google.domain: 12468+ PTR? 8.8.8.8.in-addr.arpa. (38)
17:29:37.598847 IP dns.google.domain > 10.0.2.46.52033: 12468 1/0/0 PTR dns.google. (62)
10 packets captured
14 packets received by filter
0 packets dropped by kernel

Notez qu'à la fin, un résumé vous est présenté, par exemple :

...
10 packets captured
14 packets received by filter
0 packets dropped by kernel

Important : L'option -c limite le nombre de paquets capturés.

L'option -x

Pour écouter sur une interface spécifique et voir le contenu en Hexadécimal, utilisez les options -i et -x :

root@debian12:~# tcpdump -i ens18 -x -c 3
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on ens18, link-type EN10MB (Ethernet), snapshot length 262144 bytes
17:27:24.043320 IP 10.0.2.46.ssh > 10.0.2.1.42252: Flags [P.], seq 119567701:119567889, ack 3811519061, win 501, options [nop,nop,TS val 3552922403 ecr 1647743397], length 188
        0x0000:  4510 00f0 84b8 4000 4006 9d11 0a00 022e
        0x0010:  0a00 0201 0016 a50c 0720 7555 e32f 2a55
        0x0020:  8018 01f5 1911 0000 0101 080a d3c5 4b23
        0x0030:  6236 91a5 0000 00b0 77fb cb1f c046 bb66
        0x0040:  c32f 923b a994 d49b f063 5539 130e 764b
        0x0050:  06fe b5be f2d1 7cee ef79 8d3e ec6e 1e7f
        0x0060:  c296 1fbf f4e8 67b0 f16d 5d98 1963 424c
        0x0070:  f6de 9287 5dbe 98c0 2b95 05cb 37f3 a653
        0x0080:  dbff 81a1 d03f c288 bbaf 4756 41be 64ea
        0x0090:  706a 55ff 8322 e32e ea56 2e60 5210 43e6
        0x00a0:  9eec 5bb1 e519 1936 4ee7 809b 6a18 675e
        0x00b0:  29b7 de38 921d a543 4ca7 7132 ff0f e399
        0x00c0:  5338 304d 03a3 beed ddbe 4530 cb71 fea2
        0x00d0:  618b b56d b45c 9ab6 9b71 563e 058d de9a
        0x00e0:  d249 d57e 7a53 f6b5 7bf6 5924 46f0 6c74
17:27:24.043485 IP 10.0.2.1.42252 > 10.0.2.46.ssh: Flags [.], ack 188, win 10548, options [nop,nop,TS val 1647743423 ecr 3552922403], length 0
        0x0000:  4510 0034 41fb 4000 4006 e08a 0a00 0201
        0x0010:  0a00 022e a50c 0016 e32f 2a55 0720 7611
        0x0020:  8010 2934 1855 0000 0101 080a 6236 91bf
        0x0030:  d3c5 4b23
17:27:24.125464 IP 10.0.2.46.42246 > dns.google.domain: 35092+ PTR? 1.2.0.10.in-addr.arpa. (39)
        0x0000:  4500 0043 3869 4000 4011 e603 0a00 022e
        0x0010:  0808 0808 a506 0035 002f 1c7e 8914 0100
        0x0020:  0001 0000 0000 0000 0131 0132 0130 0231
        0x0030:  3007 696e 2d61 6464 7204 6172 7061 0000
        0x0040:  0c00 01
3 packets captured
10 packets received by filter
0 packets dropped by kernel
L'option -X

Pour écouter sur une interface spécifique et voir le contenu en Hexadécimal et en ASCII, utilisez les options -i et -X :

root@debian12:~# tcpdump -i ens18 -X -c 3
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on ens18, link-type EN10MB (Ethernet), snapshot length 262144 bytes
13:07:32.922306 IP 10.0.2.46.ssh > 10.0.2.1.42252: Flags [P.], seq 119572449:119572637, ack 3811519901, win 501, options [nop,nop,TS val 3553115863 ecr 1647936856], length 188
        0x0000:  4510 00f0 84d9 4000 4006 9cf0 0a00 022e  E.....@.@.......
        0x0010:  0a00 0201 0016 a50c 0720 87e1 e32f 2d9d  ............./-.
        0x0020:  8018 01f5 1911 0000 0101 080a d3c8 3ed7  ..............>.
        0x0030:  6239 8558 0000 00b0 daef 47be bc64 8630  b9.X......G..d.0
        0x0040:  968c 107d ba16 f8fb 45db 05ff e566 a1af  ...}....E....f..
        0x0050:  728f e777 583b 64ac 09a6 f099 c570 ad4f  r..wX;d......p.O
        0x0060:  17d1 afa8 dbb3 1d59 122a 3e9d e4be 07f7  .......Y.*>.....
        0x0070:  7b85 75fc 49f4 e0fe 37ab f924 acc6 4f43  {.u.I...7..$..OC
        0x0080:  6231 f469 e3b2 ebb9 e9a4 6bfb cd89 66e2  b1.i......k...f.
        0x0090:  9fda ccf9 39ad 272a f373 167e 13e2 b56c  ....9.'*.s.~...l
        0x00a0:  3625 f2e2 7898 d061 6191 d5c4 a268 b1e0  6%..x..aa....h..
        0x00b0:  1f4a a1f9 e319 18c9 e55a b700 e281 1f71  .J.......Z.....q
        0x00c0:  06fb 4e11 1145 23e2 a194 d91c 8e22 f8ef  ..N..E#......"..
        0x00d0:  5e96 6e34 f24f 1b67 754b 4c7e 5e51 a2cf  ^.n4.O.guKL~^Q..
        0x00e0:  e2ed c5bb 409e eae3 c905 54ab cfc2 5a55  ....@.....T...ZU
13:07:32.922462 IP 10.0.2.1.42252 > 10.0.2.46.ssh: Flags [.], ack 188, win 10611, options [nop,nop,TS val 1647936883 ecr 3553115863], length 0
        0x0000:  4510 0034 4232 4000 4006 e053 0a00 0201  E..4B2@.@..S....
        0x0010:  0a00 022e a50c 0016 e32f 2d9d 0720 889d  ........./-.....
        0x0020:  8010 2973 1855 0000 0101 080a 6239 8573  ..)s.U......b9.s
        0x0030:  d3c8 3ed7                                ..>.
13:07:33.008324 IP 10.0.2.46.47533 > dns.google.domain: 49115+ PTR? 1.2.0.10.in-addr.arpa. (39)
        0x0000:  4500 0043 2e6b 4000 4011 f001 0a00 022e  E..C.k@.@.......
        0x0010:  0808 0808 b9ad 0035 002f 1c7e bfdb 0100  .......5./.~....
        0x0020:  0001 0000 0000 0000 0131 0132 0130 0231  .........1.2.0.1
        0x0030:  3007 696e 2d61 6464 7204 6172 7061 0000  0.in-addr.arpa..
        0x0040:  0c00 01                                  ...
3 packets captured
10 packets received by filter
0 packets dropped by kernel
L'option -w

Pour écouter sur une interface spécifique et envoyer la sortie dans un fichier, utilisez les options -i et -w et patientez 5 minutes :

root@debian12:~# tcpdump -i ens18 -w log.dump
tcpdump: listening on ens18, link-type EN10MB (Ethernet), snapshot length 262144 bytes
^C42 packets captured
45 packets received by filter
0 packets dropped by kernel

root@debian12:~# ls -l log.dump
-rw-r--r-- 1 tcpdump tcpdump 25555 Nov 28 13:11 log.dump

Important - Arrêtez la sortie de la commande à l'aide des touches ^C.

Notez que le fichier log.dump est au format libpcap et non au format texte. Il est donc inutile d'essayer de lire son contenu avec une commande telle cat :

root@debian12:~# file log.dump
log.dump: pcap capture file, microsecond ts (little-endian) - version 2.4 (Ethernet, capture length 262144)
L'option -v

Tcpdump peut être utilisé avec un de trois modes verbose.

Mode Option
Light verbose -v
Medium verbose -vv
Full verbose -vvv
root@debian12:~# tcpdump -i ens18 -v -c 3
tcpdump: listening on ens18, link-type EN10MB (Ethernet), snapshot length 262144 bytes
13:13:22.869956 IP (tos 0x10, ttl 64, id 34138, offset 0, flags [DF], proto TCP (6), length 176)
    10.0.2.46.ssh > 10.0.2.1.42252: Flags [P.], cksum 0x18d1 (incorrect -> 0x3397), seq 119580817:119580941, ack 3811523793, win 501, options [nop,nop,TS val 3553465811 ecr 1648286807], length 124
13:13:22.870085 IP (tos 0x10, ttl 64, id 17171, offset 0, flags [DF], proto TCP (6), length 52)
    10.0.2.1.42252 > 10.0.2.46.ssh: Flags [.], cksum 0x1855 (incorrect -> 0x174a), ack 124, win 10660, options [nop,nop,TS val 1648286831 ecr 3553465811], length 0
13:13:22.951837 IP (tos 0x10, ttl 64, id 34139, offset 0, flags [DF], proto TCP (6), length 176)
    10.0.2.46.ssh > 10.0.2.1.42252: Flags [P.], cksum 0x18d1 (incorrect -> 0x5f7e), seq 124:248, ack 1, win 501, options [nop,nop,TS val 3553465893 ecr 1648286831], length 124
3 packets captured
10 packets received by filter
0 packets dropped by kernel

1.2 - Filtrage à l'écoute

Tcpdump peut effectuer du filtrage lors de l'écoute.

Pour uniquement écouter les paquets en provenance de l'adresse IP 192.168.1.11, utilisez la condition src host :

# tcpdump src host 192.168.1.11 [Entrée]

Pour uniquement écouter les paquets en provenance de l'adresse IP 192.168.1.11 et vers l'adresse 192.168.1.2, utilisez les conditions src host et dst host :

# tcpdump src host 192.168.1.11 and dst host 192.168.1.2 [Entrée]

Pour uniquement écouter les paquets d'un port précis, utilisez la condition port :

# tcpdump -i eth0 port 80 [Entrée]

Pour uniquement écouter les paquets d'un protocole précis, utilisez une condition telle ip, icmp, arp, rarp, udp ou tcp:

# tcpdump -i eth0 udp [Entrée]

Pour uniquement écouter les paquets d'une taille inférieure à 100 octets, utilisez la condition less :

# tcpdump -i eth0 less 100 [Entrée]

Pour uniquement écouter les paquets d'une taille supérieure à 100 octets, utilisez la condition great :

# tcpdump -i eth0 greater 100 [Entrée]

L'utilisation des ses options et conditions peut être combinée pour donner des commandes telles :

# tcpdump -i eth0 -X src host 192.168.1.11 and dst host 192.168.1.2 and port 21 and ftp [Entrée]

Options de la commande

Les options de cette commande sont :

root@debian12:~# tcpdump --help
tcpdump version 4.99.3
libpcap version 1.10.3 (with TPACKET_V3)
OpenSSL 3.0.17 1 Jul 2025
Usage: tcpdump [-AbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ] [--count]
                [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
                [ -i interface ] [ --immediate-mode ] [ -j tstamptype ]
                [ -M secret ] [ --number ] [ --print ] [ -Q in|out|inout ]
                [ -r file ] [ -s snaplen ] [ -T type ] [ --version ]
                [ -V file ] [ -w file ] [ -W filecount ] [ -y datalinktype ]
                [ --time-stamp-precision precision ] [ --micro ] [ --nano ]
                [ -z postrotate-command ] [ -Z user ] [ expression ]

Les Contre-Mesures

Les contre-mesures incluent l'utilisation du chiffrement sous la forme de SSH, de SCP et d'OpenVPN.

Introduction à la cryptologie

Définitions

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

La Cryptographie

La cryptographie apporte quatre points clefs:

La cryptographie est basée sur l'arithmétique. Il s'agit, dans le cas d'un texte, de transformer les lettres qui composent le message en une succession de chiffres (sous forme de bits dans le cas de l'informatique), puis ensuite de faire des calculs sur ces chiffres pour:

Le chiffrement se fait à l'aide d'une clef de chiffrement. Le déchiffrement nécessite une clef de déchiffrement.

On distingue deux types de clefs:

Le Chiffrement par Substitution

Le chiffrement par substitution consiste à remplacer dans un message une ou plusieurs entités (généralement des lettres) par une ou plusieurs autres entités. On distingue généralement plusieurs types de cryptosystèmes par substitution :

Algorithmes à clé secrète

Le Chiffrement Symétrique

Ce système est aussi appelé le système à Clef Secrète ou à clef privée.

Ce système consiste à effectuer une opération de chiffrement par algorithme mais comporte un inconvénient, à savoir qu'il nécessite un canal sécurisé pour la transmission de la clef de chiffrement/déchiffrement.

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

Important - Le système de Méthode du Masque Jetable (One Time Pad) fût mis au point dans les années 1920. Il utilisait une clef générée aléatoirement à usage unique.

Les algorithmes de chiffrement symétrique couramment utilisés en informatique sont:

Algorithmes à clef publique

Le Chiffrement Asymétrique

Ce système est aussi appelé Système à Clef Publique.

Ce système consiste à avoir deux clefs appelées des bi-clefs:

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

Ce système est basé sur ce que l'on appelle une fonction à trappe à sens unique ou one-way trap door.

Il existe toutefois un problème – s'assurer que la clef publique récupérée est bien celle qui correspond au destinataire !

Les algorithmes de chiffrement asymétrique couramment utilisés en informatique sont:

La Clef de Session

Ce système est un compromis entre le système symétrique et le système asymétrique. Il permet l'envoie de données chiffrées à l'aide d'un algorithme de chiffrement symétrique par un canal non-sécurisé et a été mis au point pour palier au problème de lenteur de déchiffrement du système asymétrique.

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

Ce système fonctionne de la façon suivante :

Fonctions de Hachage

La fonction de hachage, aussi appelée une fonction de condensation, est à sens unique (one way function). Il « condense » un message en clair et produit un haché unique.

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

Les deux algorithmes de hachage utilisés sont:

Lors de son envoie, le message est accompagné de son haché et il est donc possible de garantir son intégrité:

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

Important - Ce système permet de vérifier que l'empreinte correspond bien au message reçu, mais ne permet pas de prouver que le message a bien été envoyé par l’utilisateur A.

Signature Numérique

Pour garantir l'authentification du message l‘utilisateur A va chiffrer ou signer le haché à l'aide de sa clé privée. Le haché signé est appelé un sceau.

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

Ce mécanisme de création de sceau est appelé scellement.

Ce mécanisme est identique au procédé utilisé par SSH lors d'une connexion

PKI

On appelle PKI (Public Key Infrastucture, ou en français infrastructure à clé publique (ICP), parfois infrastructure de gestion de clés (IGC)) l’ensemble des solutions techniques basées sur la cryptographie à clé publique.

Les cryptosystèmes à clés publiques permettent de s'affranchir de la nécessité d'avoir recours systématiquement à un canal sécurisé pour s'échanger les clés. En revanche, la publication de la clé publique à grande échelle doit se faire en toute confiance pour assurer que :

Ainsi, il est nécessaire d'associer au bi-clé (ensemble clé publique / clé privée) un certificat délivré par un tiers de confiance : l'infrastructure de gestion de clés.

Le tiers de confiance est une entité appelée communément autorité de certification (ou en anglais Certification authority, abrégé CA) chargée d'assurer la véracité des informations contenues dans le certificat de clé publique et de sa validité.

Pour ce faire, l'autorité signe le certificat de clé publique à l'aide de sa propre clé en utilisant le principe de signature numérique.

Le rôle de l'infrastructure de clés publiques est multiple et couvre notamment les champs suivants :

Une infrastructure à clé publique est en règle générale composée de trois entités distinctes :

Certificats X509

Pour palier aux problèmes liés à des clefs publiques piratées, un système de certificats a été mis en place.

Le certificat permet d’associer la clef publique à une entité ou une personne. Les certificats sont délivrés par des Organismes de Certification.

Les certificats sont des fichiers divisés en deux parties :

La structure des certificats est normalisée par le standard X.509 de l’Union internationale des télécommunications.

Elle contient :

Le Certificat est signé par l'autorité de certification:

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

La vérification se passe ainsi:

Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.

LAB #2 - Utilisation de GnuPG

2.1 - Présentation

GNU Privacy Guard permet aux utilisateurs de transférer des messages chiffrés et/ou signés.

2.2 - Utilisation

Pour initialiser GnuPG, saisissez la commande suivante :

root@debian12:~# gpg
gpg: directory '/root/.gnupg' created
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
gpg: Go ahead and type your message ...
^C
gpg: signal Interrupt caught ... exiting

Important - Notez l'utilisation des touches ^C après la ligne gpg: Go ahead and type your message ….

Pour générer les clefs, saisissez la commande suivante :

Important - Lorsque le système vous demande une Passphrase, saisissez une valeur que n'allez PAS oublié.

root@debian12:~# gpg --full-generate-key
gpg (GnuPG) 2.2.40; Copyright (C) 2022 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
  (14) Existing key from card
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (3072) 
Requested keysize is 3072 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: ITTRAINING
Email address: infos@ittraining.team
Comment: Test key
You selected this USER-ID:
    "ITTRAINING (Test key) <infos@ittraining.team>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: directory '/root/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/root/.gnupg/openpgp-revocs.d/B6022CC107539B4036A90FAEABAD13CD27F9E686.rev'
public and secret key created and signed.

pub   rsa3072 2025-11-28 [SC]
      B6022CC107539B4036A90FAEABAD13CD27F9E686
uid                      ITTRAINING (Test key) <infos@ittraining.team>
sub   rsa3072 2025-11-28 [E]

La liste de clefs peut être visualisée avec la commande suivante :

root@debian12:~# gpg --list-keys
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
/root/.gnupg/pubring.kbx
------------------------
pub   rsa3072 2025-11-28 [SC]
      B6022CC107539B4036A90FAEABAD13CD27F9E686
uid           [ultimate] ITTRAINING (Test key) <infos@ittraining.team>
sub   rsa3072 2025-11-28 [E]

Pour importer la clef d'un correspondant dans sa trousse de clefs il convient d'utiliser la commande suivante :

Important - La commande suivante est un exemple. Ne la saisissez PAS.

# gpg --import la-clef.asc

Pour exporter sa clef publique, il convient d'utiliser la commande suivante :

root@debian12:~# gpg --export --armor ITTRAINING > ~/mykey.asc

root@debian12:~# cat mykey.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQGNBGkpk+gBDACq6M7rUNQFu/R6J+1p3RAB1+gwnszs/jZuBAo6y9i1buBsySP9
oV9JmFfRe4P2QG/mgmSaGgeO0sE5m+r2Jhif2fShjHYLd6VTSVZRyfO+NW3MDbkm
MtIf4LlXRrTALGE5TclLWFz5a2iqRjtT8IjSPAu1M9TLUaMXtWXN6jQY1YOnjxPN
3HL8bwdaY0k8icKr8JRbmEijCWo2F4t2qTtdOXuRFAImxBpX49eJR0oC5bzXZPYx
LbirNsEwSULIyQ71gdF5OUb0aOSiQLXLuTLAs2BnxAJ82tB/dM8qP0ez0lXLJvvF
+t0eHdWzUHH4qlXuNtBXK7pEbvjqftO69PJLDp/PwjEfUsELcxDyUFpphhZDJ8zN
qvRgll3fojjr91WWWqr8YTd4EiTvq9KfUyAiTOfKm8k4iRQRTJir267Fq8Mno8/B
My1tNeHWzCXMs3k/GKyi36Uu15wY50hRTPDYexa+aou0QEs4iY3EXjzaOD3BVvRQ
XTBUX/CS3ZmLC3MAEQEAAbQtSVRUUkFJTklORyAoVGVzdCBrZXkpIDxpbmZvc0Bp
dHRyYWluaW5nLnRlYW0+iQHOBBMBCgA4FiEEtgIswQdTm0A2qQ+uq60TzSf55oYF
Amkpk+gCGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQq60TzSf55oZEsAv+
Ky14vHWjMzU1ieE+XStqGYfjfAHhaNrpkWCz6miozuh+ESifNWpJd96bzwgNLGob
E5mA9oja5jyAEQUGT+gEwgvkbYVe4sf4UcXPRrvDqKiEOkN5rra3kYYdhHhpiFes
BmwQvW2dyElNO1ee/zzQOZ0Hd3vM/vdbmZRg8zKoV5eQz/MA2jpxF9IkXEDtUMzZ
C5kqTMRXdoWR2ZP2HLZjUstRX7d9BP/8oeg+2lMq9UlULWrYyVaD85dEAmCt9mQz
TqtAMmtp5IXalT+vKwhMu0MwUfyXyvl7ery4kxfmFtEeJQyxrdK2gihDxr0ndxBH
mowlIoBiGYMhUr/aF0lM00blpRAUoGv1rO2DUWh8TXzRJq6FJ4pzo9XRwR0dP7A6
VBlBdhX2SlE9XJOjLq9ppV5Vr9u6ZauwEI6kBLoagjWOF3t34Gnvel8zO+H5fhhq
UKMOAbC0SYmLVIPNUauHYoKiJlWb+Dlr96NsPm0sYBbB047hr0evBUmkJNrulI3N
uQGNBGkpk+gBDADZu1B0itmBIGzxjGmUjK9UagW3HNLNVX3jn2Jwe7yl3vL/d3Fk
qBRydky32P4whbUSiJN71Tze9l+WOxeXGa0orKPPha/oQtlnmqyM6WBfOmvjSQkn
xCrS131SYjFb5dcQXoqTtUk8Wu4qoMHu/Mi9jtx8GrrENWzR7DFG2MDWwcM4TmUk
zs6azU/jaQX/YrGmYU3vB/zpKEZSo89pJ/S2FQ/6Fr+nnh7El3thNJxLRH40UlZs
FIpfm95Q+wtC224wckro/Xf/+t7oBssSqCZEkCItN+AlDpm13h161dypVRpC1M5Y
IITHq92gQSAKFhwSauaPtJ++oQNRgz5vJhCg78XfyBGpwDS6P0NM5RVEz6LMhQzI
4LziGmYH/iWj0pv45Uze7hOZaWhBPlPWFixJ97nl3soxA7hV1MLt/Ohy5jxGC8U3
CrtEjyAIQxCmEUF0vPa7X1KB+FxCpJ8mYXBZ5w1DwBN7qsOnnHZKFcaPGW8r1am6
Ab25ee028mua9RkAEQEAAYkBtgQYAQoAIBYhBLYCLMEHU5tANqkPrqutE80n+eaG
BQJpKZPoAhsMAAoJEKutE80n+eaGCRgMAJiG7Q8oF6oMkn6Xh7kXVH2yF4CKN9/j
/qtImK/ikn14+/QNYpUbF4kIGadeCVgpKZZ+R9QLXTW7WQV4hgoOW3yiET3FTEBc
YoxDxegwlk9+gPiOMJ0+9R43IUs+jFrra1jcUpSg+1Nv2IijdPwape3HyPhYgDmZ
VxORrNtqBCkhtLpJO5VTiThAny+rNBHk1t1vQg4tEkCLGcOD8bsdxhACZnM0DVYY
rA6afeDnm7CTfVtc3QFAi2+ltYcDIrMxMF0b1VASlbU14TE6ep2Ic30ScpDJL8De
skhWi2/0v2WwhbmdGzfv5K5V3Z6NtoB3OUaHzKqzgEQeqjudgRaL440UsDtEFRHE
vh6kVR0MPTFjg+8khUjjrSYUzqiiK6iJDxn+m0XJvHzQTeCHQlgRrPj9HGp7isyK
o9Wf8fVvnksR8xc/2NcJwp0fo7ULwdADjgMtPUR155ukI8Xt9Aws+5OsYrIxBMMc
DTh6aJal6iGcG4aXbTzwIFXHW9WipS5B4A==
=rrxA
-----END PGP PUBLIC KEY BLOCK-----

Cette clef peut ensuite être jointe à des messages électroniques ou bien déposée sur un serveur de clefs tel http://www.keyserver.net.

Signer un message

Créez maintenant un message à signer :

root@debian12:~# vi message.txt

root@debian12:~# cat message.txt
# ~/message.txt
Ceci est un message de test pour GnuPG

Pour signer ce message en format binaire, il convient d'utiliser la commande suivante :

Important - Entrez votre Passphrase quand gpg vous la demande.

root@debian12:~# gpg --default-key ITTRAINING --detach-sign message.txt
gpg: using "ITTRAINING" as default secret key for signing

root@debian12:~# ls -l | grep message
-rw-r--r-- 1 root    root         55 Nov 28 13:28 message.txt
-rw-r--r-- 1 root    root        461 Nov 28 13:28 message.txt.sig

root@debian12:~# cat message.txt.sig

4!,S@6'i)infos@ittraining.team
        '|
                M<~,#5@^0F6ܝӎl`6fA(897>"Bj\     N!M.=F[3tC"%Fk@{6ƒbbEcc2'Smhlwmޚ)<AICA$U^*DPI0ʘ)'p-4d{EiU\P`9}%L0RНGڕ(-y$i'fǬCBH^c      ;pQbٜbJeqKh7I/6FLc7kUi}/%3xeOv;i13Ĭ

Pour signer ce message en format ascii, il convient d'utiliser la commande suivante :

root@debian12:~#  gpg --default-key ITTRAINING --armor --detach-sign message.txt

gpg: using "ITTRAINING" as default secret key for signing

root@debian12:~# ls -l | grep message
-rw-r--r-- 1 root    root         55 Nov 28 13:28 message.txt
-rw-r--r-- 1 root    root        691 Nov 28 13:31 message.txt.asc
-rw-r--r-- 1 root    root        461 Nov 28 13:28 message.txt.sig

root@debian12:~# cat message.txt.asc
-----BEGIN PGP SIGNATURE-----

iQHKBAABCgA0FiEEtgIswQdTm0A2qQ+uq60TzSf55oYFAmkplgkWHGluZm9zQGl0
dHJhaW5pbmcudGVhbQAKCRCrrRPNJ/nmhiteC/kBXVFzjOQYIzdt4ALI37gCmd7x
Ml72F9permfoLc83fj+zZfigUxZe4DHx0TslVtFhntkg+7wF1H3MmUyKOhwCXFO4
ccyE9/DDJR384muuAP1q05bnXz0SHkTQaXVteCvAfHB8kzqQg04ePCBcIWK6YQVv
MBVm2O4pFDXWu1+0S69YnAelElZrzoqCaqprkQCcJvekBSV2NUNPLcwcBGq966+q
T9bGxPtW/5oTaPfFRzWwT/47ajpB66v3kEyGlc+gMpD4PFKZhLoEpgpByBWRWvhm
ZQsz2eby3oyv5KduA2emMnstQGCBq6zukYUpTgtzXB6jF1S71okiow11NsPra0m+
9CAcg3tiylnkUJEgsvfZ45uctN+2UqBNAXMgVsHGUhJtugfPzfwWpfC/BMMdLS46
g2nTttJexAGjjtw4Y0uFIYbNI0xXeH8ooh0AgQcXS5IOVH2zYs0GIdMxzRYFhRmc
nVRd/mHfQ21Mi1C5AnxDkqx6RpeH1maaLsPOFlo=
=2N1N
-----END PGP SIGNATURE----- 

Pour signer ce message dans le message lui-même en format ascii, il convient d'utiliser la commande suivante :

root@debian12:~# gpg --default-key ITTRAINING --clearsign message.txt
gpg: using "ITTRAINING" as default secret key for signing
File 'message.txt.asc' exists. Overwrite? (y/N) y

root@debian12:~# ls -l | grep message
-rw-r--r-- 1 root    root         55 Nov 28 13:28 message.txt
-rw-r--r-- 1 root    root        795 Nov 28 13:33 message.txt.asc
-rw-r--r-- 1 root    root        461 Nov 28 13:28 message.txt.sig

root@debian12:~# cat message.txt.asc
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

# ~/message.txt
Ceci est un message de test pour GnuPG
-----BEGIN PGP SIGNATURE-----

iQHKBAEBCgA0FiEEtgIswQdTm0A2qQ+uq60TzSf55oYFAmkplpsWHGluZm9zQGl0
dHJhaW5pbmcudGVhbQAKCRCrrRPNJ/nmhopQC/wJYnC83AnA54x9O9FzHIQ0YVqO
QzcoDIIDMF71lizXIQ4DL2GCKhO3pelEWfyofUxd1sddT2qIHIsRTULaqHPRRjOU
9e/Wm9i65aUnQ/o5oDLSuHooi/r3HYPr8tHDhNSXT81a/QQ0BYVpMHVW/LREtw+L
qNPNlSZ4kzim3LyASyg8SYTGfft35S1S+7bjoY7LHfJUlGuSFRtlDMlhTbrrDqhI
S3TL6EeNFCdEVoxCPamsAKvuk4BV8Fe2rCjQqm/D6f0l+bgdnGFnd5y+nCiz0xXF
i7lQkZz+IjoTqwrjboL1mPWt6DMgiBX0IWas4kxKiBeZzyDZm6HGNeeMsqnReTcR
TPNM9FdDmpcxYzrRbYAoWTmdhiPdD/aXPEp+McyNIwwHgduUWuRGcifP2PVw6j0N
i3yOFw/rJEZMQnjwuL0GUSO3o8j1WMcSsTOHqsgu5FSKSjiIelNK2gzHTkuFiJ/7
scYMCHrlrUfErpkLD1H6eFhSA4StmdZPmAA5DBA=
=07RM
-----END PGP SIGNATURE-----

Pour vérifier la signature d'un message signé en mode ascii, il convient d'utiliser la commande :

root@debian12:~# gpg --verify message.txt.asc
gpg: Signature made Fri 28 Nov 2025 01:33:31 PM CET
gpg:                using RSA key B6022CC107539B4036A90FAEABAD13CD27F9E686
gpg:                issuer "infos@ittraining.team"
gpg: Good signature from "ITTRAINING (Test key) <infos@ittraining.team>" [ultimate]
gpg: WARNING: not a detached signature; file 'message.txt' was NOT verified!

Important - Pour vérifier la signature d'un message signé en mode ascii et produit en dehors du message lui-même, il convient d'utiliser la commande :

# gpg --verify message.txt.asc message.txt

Chiffrer un message

Pour chiffrer un message, il faut disposer de la clef publique du destinataire du message. Ce dernier utilisera ensuite sa clef privée pour déchiffrer le message. Il convient de préciser le destinataire du message, ou plus précisément la clef publique à utiliser, lors d'un chiffrement :

  gpg --recipient <destinataire> --encrypt <message>

Par exemple pour chiffrer un message en mode binaire, il convient de saisir la commande suivante :

root@debian12:~# gpg --recipient ITTRAINING --encrypt message.txt

root@debian12:~# ls -l | grep message
-rw-r--r-- 1 root    root         55 Nov 28 13:28 message.txt
-rw-r--r-- 1 root    root        795 Nov 28 13:33 message.txt.asc
-rw-r--r-- 1 root    root        510 Nov 28 13:35 message.txt.gpg
-rw-r--r-- 1 root    root        461 Nov 28 13:28 message.txt.sig

root@debian12:~# cat message.txt.gpg
ӛS4
   t>25H@H:x+H  n֩ˁ+B.^2Zھ~~~´4sd27J    ~:W^}ĀzmI]/e=kS׈n9tȘQ=Cj5{Q
                                                                   #0"  @qw,\[B$(:BU舏9^8_Qa 
                                                                                             e^4,鹫     k/Pj#y:j~PU(}K#tTT-AZu  1z!%]t{
                                                                                                                                        5?"a5Vdnn$\V#(ctWhce6/-qThy^Ъmk-$$Dn
                                                                                                                                                                            ^&Mw.*ԬYrɺޕr}o/Q[X_)Wr?U0gMV,">9Croot@debian12:~#

Et pour chiffrer un message en mode ascii, il convient de saisir la commande suivante :

root@debian12:~# gpg --recipient ITTRAINING --armor --encrypt message.txt
File 'message.txt.asc' exists. Overwrite? (y/N) y

root@debian12:~# ls -l | grep message
-rw-r--r-- 1 root    root         55 Nov 28 13:28 message.txt
-rw-r--r-- 1 root    root        752 Nov 28 13:38 message.txt.asc
-rw-r--r-- 1 root    root        510 Nov 28 13:36 message.txt.gpg
-rw-r--r-- 1 root    root        461 Nov 28 13:28 message.txt.sig

root@debian12:~# cat message.txt.asc
-----BEGIN PGP MESSAGE-----

hQGMA9ObUzTZ86GvAQwAxAGoxKHBMh53+bPqHs338vhWjxAZs19aItMm+CM2pKu5
i4euJ36o+oVfbVTcqVNh4Q8I72QTOYTRTeXRWaUtVjp055A07BtlxGPbps9GXkVv
1faIs8viwHF1FHDC3Iz/SSf7u7tSF6sxbU6B4c/fHPneKjUxesH0XmKjduEdpDPj
ylZxPngzTOR4RDbMbkZ5OvJKXNrOOiHUSDOMmI9o9nu7sxnMiPP3NUqilN/0NtFz
xveV/mqDOEHT7Q1IHR+kN0e7WHqCl4NOvh0BXhL5u+9m18pgRe6ZvC6E94e+yPxZ
21umlYbcIPtw87+h9twBj7vK5FUi7j8C5QWoDoM4XERf/v21A1fTlx2cDn8E1lOC
dTaZlgTtxM3CY7/iWlG7TXWfUQfdZWhf/Mz1bHguljeOqVMGTI/zCElDnS3Ezzhg
bIlrpLbs6yqtjant1bkZ5PuNhB1bRNxrSKZUZKdEMeY5M+C0GjKskjN84+OqgjRV
39GkfPDwqw/eBj0ldvc60m0B5H2ZIIRApWl4j9RGhe2ZbvS+ZmI2vSf75RPDcNyH
PKDwHyTKCGN3NQKOIrw9LbIXehYEdrdFwGizGUXba1EWwVs+qMsmFueoQfcvA19N
CJ2HPuO3qAVIDpYyX+vwdKQASbb8AMQIIksoQv7i
=481C
-----END PGP MESSAGE-----

Pour décrypter un message il convient d'utiliser la commande suivante :

root@debian12:~# gpg --decrypt message.txt.asc
gpg: encrypted with 3072-bit RSA key, ID D39B5334D9F3A1AF, created 2025-11-28
      "ITTRAINING (Test key) <infos@ittraining.team>"
# ~/message.txt
Ceci est un message de test pour GnuPG

LAB #3 - Mise en place de SSH et SCP

3.1 - Introduction

La commande ssh est le successeur et la remplaçante de la commande rlogin. Il permet d'établir des connexions sécurisées avec une machine distante. SSH comporte cinq acteurs :

SSH fonctionne de la manière suivante pour la la mise en place d'un canal sécurisé:

SSH-1

SSH-1 utilise une paire de clefs de type RSA1. Il assure l'intégrité des données par une Contrôle de Redondance Cyclique (CRC) et est un bloc dit monolithique.

Afin de s'identifier, le client essaie chacune des six méthodes suivantes :

SSH-2

SSH-2 utilise DSA, RSA, ecdsa ou ed25519. Il assure l'intégrité des données par l'algorithme HMAC. SSH-2 est organisé en trois couches :

SSH-2 diffère de SSH-1 essentiellement dans la phase authentification.

Trois méthodes d'authentification :

L'authentification par mot de passe

L'utilisateur fournit un mot de passe au client ssh. Le client ssh le transmet de façon sécurisée au serveur ssh puis le serveur vérifie le mot de passe et l'accepte ou non.

Avantage:

Inconvénients:

L'authentification par clef asymétrique

3.2 - Configuration du Serveur

La configuration du serveur s'effectue dans le fichier /etc/ssh/sshd_config :

root@debian12:~# cat /etc/ssh/sshd_config

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/bin:/usr/games

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Include /etc/ssh/sshd_config.d/*.conf

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile     .ssh/authorized_keys .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
KbdInteractiveAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin prohibit-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

# override default of no subsystems
Subsystem       sftp    /usr/lib/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server

Pour ôter les lignes de commentaires dans ce fichier, utilisez la commande suivante :

root@debian12:~# cd /tmp ; grep -E -v '^(#|$)'  /etc/ssh/sshd_config > sshd_config

root@debian12:/tmp# cat sshd_config
Include /etc/ssh/sshd_config.d/*.conf
KbdInteractiveAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem       sftp    /usr/lib/openssh/sftp-server

Pour sécuriser le serveur ssh, ajoutez ou modifiez les directives suivantes :

AllowGroups adm
Banner /etc/issue.net
HostbasedAuthentication no
IgnoreRhosts yes
LoginGraceTime 60
LogLevel INFO
PermitEmptyPasswords no
PermitRootLogin no
PrintLastLog yes
Protocol 2
StrictModes yes
X11Forwarding no

Votre fichier ressemblera à celui-ci :

root@debian12:/tmp# cat sshd_config
Include /etc/ssh/sshd_config.d/*.conf
KbdInteractiveAuthentication no
UsePAM yes
PrintMotd no
AcceptEnv LANG LC_*
AllowGroups adm
HostbasedAuthentication no
IgnoreRhosts yes
LoginGraceTime 60
LogLevel INFO
PermitEmptyPasswords no
PermitRootLogin no
PrintLastLog yes
Protocol 2
StrictModes yes
X11Forwarding no
Subsystem       sftp    /usr/lib/openssh/sftp-server

Mettez l'utilisateur trainee dans le groupe adm

root@debian12:/tmp# groups trainee
trainee : trainee cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers

root@debian12:/tmp# usermod -a -G adm trainee

root@debian12:/tmp# groups trainee
trainee : trainee adm cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers

Renommez le fichier /etc/ssh/sshd_config en /etc/ssh/sshd_config.old puis copiez le fichier /tmp/sshd_config vers /etc/ssh/ :

root@debian12:/tmp# mv /etc/ssh/sshd_config /etc/ssh/sshd_config.old

root@debian12:/tmp# cp sshd_config /etc/ssh

Redémarrez ensuite le serveur ssh :

root@debian12:/tmp# systemctl restart ssh

root@debian12:/tmp# systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; preset: enabled)
     Active: active (running) since Fri 2025-11-28 15:18:55 CET; 7s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 10882 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 10883 (sshd)
      Tasks: 1 (limit: 19123)
     Memory: 1.4M
        CPU: 28ms
     CGroup: /system.slice/ssh.service
             └─10883 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Nov 28 15:18:55 debian12 systemd[1]: Starting ssh.service - OpenBSD Secure Shell server...
Nov 28 15:18:55 debian12 sshd[10883]: Server listening on 0.0.0.0 port 22.
Nov 28 15:18:55 debian12 sshd[10883]: Server listening on :: port 22.
Nov 28 15:18:55 debian12 systemd[1]: Started ssh.service - OpenBSD Secure Shell server.

Pour générer les clefs sur le serveur saisissez la commande suivante en tant que root:

Important - Lors de la génération de la clef, la passphrase doit être vide.

root@debian12:/tmp# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa): /etc/ssh/ssh_host_dsa_key
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /etc/ssh/ssh_host_dsa_key
Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub
The key fingerprint is:
SHA256:mP/fGCXEcyZQ+afGDrQK4S1TYVIw3pnBre25MPU2b3g root@debian12
The key's randomart image is:
+---[DSA 1024]----+
|        o++o..   |
|       ..o+*o    |
|        .o++=.o  |
|       o. o.+=. .|
|      o.S+ +.=.o |
|       .= + =oB  |
|        .+ +.* + |
|         .. .+o E|
|          ..o .o |
+----[SHA256]-----+

Important - Le chemin à indiquer pour le fichier est /etc/ssh/ssh_host_dsa_key. De la même façon, il est possible de générer les clefs au format RSA, ECDSA et ED25519.

Les clefs publiques générées possèdent l'extension .pub. Les clefs privées n'ont pas d'extension :

root@debian12:/tmp# ls /etc/ssh
moduli      ssh_config.d  sshd_config.d    ssh_host_dsa_key      ssh_host_ecdsa_key      ssh_host_ed25519_key      ssh_host_rsa_key
ssh_config  sshd_config   sshd_config.old  ssh_host_dsa_key.pub  ssh_host_ecdsa_key.pub  ssh_host_ed25519_key.pub  ssh_host_rsa_key.pub

Re-démarrez ensuite le service sshd :

root@debian12:/tmp# systemctl restart ssh

Saisissez maintenant les commandes suivantes en tant que trainee :

Important - Lors de la génération des clefs, la passphrase doit être vide.

root@debian12:/tmp# exit
logout

trainee@debian12:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/trainee/.ssh/id_dsa): 
Created directory '/home/trainee/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/trainee/.ssh/id_dsa
Your public key has been saved in /home/trainee/.ssh/id_dsa.pub
The key fingerprint is:
SHA256:97XNFS0p/j8IaR7sByO1jVTE3sP23l/qDRUwU9TFRpw trainee@debian12
The key's randomart image is:
+---[DSA 1024]----+
|            o=o**|
|             o+E*|
|            + =+.|
|           + o *o|
|        S = * o =|
|         o % + =o|
|          = * =.=|
|           o o *+|
|            ..o *|
+----[SHA256]-----+

trainee@debian12:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/trainee/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/trainee/.ssh/id_rsa
Your public key has been saved in /home/trainee/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:p2xPZdoPCICy/D5x0g+nHilsV6Ar4UMwmHeRnHDnBQw trainee@debian12
The key's randomart image is:
+---[RSA 3072]----+
|  .oE=o..        |
|.. .+=..         |
|= o o +          |
| = + . o         |
|  = ..  S . o    |
| o +o.++.+ *     |
|  + *++=+ + o    |
|   =.o.o.o   o   |
|    .o.   .   .  |
+----[SHA256]-----+

trainee@debian12:~$ ssh-keygen -t ecdsa
Generating public/private ecdsa key pair.
Enter file in which to save the key (/home/trainee/.ssh/id_ecdsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/trainee/.ssh/id_ecdsa
Your public key has been saved in /home/trainee/.ssh/id_ecdsa.pub
The key fingerprint is:
SHA256:zA3muePCJZ7SCIvuKe+X5veMqWpP0UTr6HAVv+LPBCo trainee@debian12
The key's randomart image is:
+---[ECDSA 256]---+
|      o          |
|     . +         |
|      + +        |
|     * = =       |
|  . + = S .      |
|  .+ +.o..       |
| .Eo+*.++        |
|o +o* BO .       |
|+B+*++oo*        |
+----[SHA256]-----+

trainee@debian12:~$ ssh-keygen -t ed25519
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/trainee/.ssh/id_ed25519): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/trainee/.ssh/id_ed25519
Your public key has been saved in /home/trainee/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:f5GzguZoS5SN2EQDyj7zAqES+7PDOBSJRg+lD+vpn3Q trainee@debian12
The key's randomart image is:
+--[ED25519 256]--+
|  ....o          |
| +.. . .         |
|=o*   .          |
|oO+. + +     .   |
|*.=.. = S   +    |
|o+.+ .   o   +   |
|.=+..E. o o o    |
|+ ++o..+   o     |
| oo+ .o..        |
+----[SHA256]-----+

Important - Les clés générées seront placées dans le répertoire ~/.ssh/.

3.3 - Utilisation

La commande ssh prend la forme suivante:

ssh -l nom_de_compte numero_ip (nom_de_machine)

En saisissant cette commande sur votre propre machine, vous obtiendrez un résultat similaire à celle-ci :

trainee@debian12:~$ su -
Password: fenestros
root@debian12:~#

root@debian12:~# ssh -l trainee localhost
The authenticity of host 'localhost (::1)' can't be established.
ED25519 key fingerprint is SHA256:SS9CpX7JFHIB54TWQWTtyswnwaXZ/Y8Kvr6dxPtisgE.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'localhost' (ED25519) to the list of known hosts.
trainee@localhost's password: 
Linux debian12 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Nov 27 17:21:12 2025 from 10.0.2.1

3.4 - Mise en place des clefs

Il convient maintenant de se connecter sur le «serveur» en utilisant ssh et vérifiez la présence du répertoire ~/.ssh :

En saisissant cette commande, vous obtiendrez une fenêtre similaire à celle-ci :

root@debian12:~# exit
logout

trainee@debian12:~$ ssh -l trainee 127.0.0.1
trainee@127.0.0.1's password: trainee
Linux debian12 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Nov 28 15:31:58 2025 from 10.0.2.46

trainee@debian12:~$ ls -la | grep .ssh
drwx------   2 trainee trainee 4096 Nov 28 15:29 .ssh

trainee@debian12:~$ exit
logout
Connection to 127.0.0.1 closed.

Important - Si le dossier distant .ssh n'existe pas dans le répertoire personnel de l'utilisateur connecté, il faut le créer avec des permissions de 700. Dans votre cas, puisque votre machine joue le rôle de serveur et du client, le dossier /home/trainee/.ssh existe déjà.

Ensuite, il convient de transférer le fichier local .ssh/id_ecdsa.pub du «client» vers le «serveur» en le renommant en authorized_keys :

trainee@debian12:~$ scp .ssh/id_ecdsa.pub trainee@127.0.0.1:/home/trainee/.ssh/authorized_keys
trainee@127.0.0.1's password: 
id_ecdsa.pub                                                                                                                                                                    100%  178   399.6KB/s   00:00 

Connectez-vous via ssh et insérer les clefs publiques restantes dans le fichier .ssh/authorized_keys :

trainee@debian12:~$ ssh -l trainee localhost
Linux debian12 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Nov 28 15:57:32 2025 from 127.0.0.1

trainee@debian12:~$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys

trainee@debian12:~$ cat .ssh/id_dsa.pub >> .ssh/authorized_keys

trainee@debian12:~$ cat .ssh/id_ed25519.pub >> .ssh/authorized_keys

trainee@debian12:~$ cat .ssh/authorized_keys
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBwIXLMYJtWVgqSTqJfsFjS2ubtP+mHkC7XRU1rBWTBLYoJp8VOwtpKK1NTFSaeJhnjCvFuhYm8egqHI0gp3oBA= trainee@debian12
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDcV1OmeHZlWhLumCozdg7snul5MrkzhZjiUKWNJmGBBOauOq2CgMGYWYIhjyeVeaeiezq+wSe0jO09p8a1EbvYUibJsY9FOi8JcXTpxvlcqpuawudErjSsOf6JaIlbGpwDIMzmjeubfQx9jMZzfQIW9zfTDUi2tGquR/1TQPocGmmI9JFtoMqylk4+KsIHpriMBEVD/aKiGr1wjLHR1v3er8P1o8YOd+9tZXouJxWLHIA1swrnpXt8doVWYGx0E9jWsScqI4JPTy8kb2hfWeZWqONIqgJty0kOeTt6IynOauf9fSjxOG9Y4jyTV/OvTrBrmOCabjTIVMaIOWjLIPjNKJ8+eLnv+FuKUCc9mrAjbkXaP8T3JF43ofaBgSk09S3yo6wI3XI8ZlgROLDt7xxbFKosK/tYe8uOkpladNQHq3+EhAmzsfZJIstY0tNeK7aQ2KlsH6hZkLpqHsoKdzsLhRpMuPnV7wNlrikrbcvousDdQBpnzhNaXcm2BW+jmOs= trainee@debian12
ssh-dss AAAAB3NzaC1kc3MAAACBAMbFW6WkZFJ/ueao6xjxBb+wbbIhIyiH/GM6W/7ayiNmCfFlYCxw9nNAVghYJYNcP2hB+l0qZ0JYrOMUX82sXAvtYbbO1xSZWNTTrbYEyR+o2ZWlgYBDz0DYj++dLCl0zCGHOfRq2VHtCx93mCxCiw5NXNflxOuy2WoY7hawxV/RAAAAFQDURMf0f29i5or5GrE4JWlFVZbiIwAAAIBqGpwpz+uQTKpJmgiisVA1t/0MRP2YstUVnU29Nr/C7EJ3bom3wx4At/bbQEfc7iVf0pwRUSJhdTy4t2vnFWghoeoj2ALUA4QVarVr7m0TY7m8bYgAlPVBx674DDmHfUh99PTwYcrcJUJMpVd+mwVccnXGigpHhs84QvD6csmxCwAAAIAEtC/YVdYAxFUd+ScG0zrBSsPHA/cigCF5cywNeu+OZqrK2y6yiJwp9T9bCL2nvzTWeTg/2Ev7v7Zh2oNKE5/mUoTDDn22omefi9Ecxl9W6Pyi8R6PxV+8mXtjHKPVNEQyqA8tAG1VN33MMgWz5HUEdwdUrOcmrkpyXNsRzvgD6w== trainee@debian12
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILP736HSOOTZBe6+CHy8PINQ4gb9kKB4xj0JWWZy1Wgl trainee@debian12

Important - Notez que lors de la connexion au serveur, l'authentification utilise le couple de clefs asymétrique et aucun mot de passe n'est requis.

Options de la commande

Les options de cette commande sont :

trainee@debian12:~$ ssh --help
unknown option -- -
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
           [-i identity_file] [-J [user@]host[:port]] [-L address]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-Q query_option] [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] destination [command [argument ...]]

3.5 - Tunnels SSH

Le protocole SSH peut être utilisé pour sécuriser les protocoles tels telnet, pop3 etc.. En effet, on peut créer un tunnel SSH dans lequel passe les communications du protocole non-sécurisé.

La commande pour créer un tunnel ssh prend la forme suivante :

ssh -N -f compte@<hôte_local> -L<port-local>:<hôte_distant>:<port_distant>

Dans votre cas, vous allez créer un tunnel entre Debian 12 et CentOS 8 entre le port 15023 et le port 23 :

trainee@debian12:~$ su -
Password: fenestros

root@debian12:~# ssh -N -f trainee@localhost -L15023:10.0.2.45:23

Installez maintenant le client et le serveur telnet dans la VM CentOS 8:

root@debian12:~# ssh -l trainee 10.0.2.45
The authenticity of host '10.0.2.45 (10.0.2.45)' can't be established.
ED25519 key fingerprint is SHA256:YRt3r4qD/pZ8PoJ2irS3bH2miZj6/O3/kS4CBlcbz84.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.2.45' (ED25519) to the list of known hosts.
trainee@10.0.2.45's password: trainee
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Thu Nov  6 04:13:03 2025 from 10.0.2.45

[trainee@centos8 ~]$ su -
Password: fenestros

[root@centos8 ~]# dnf install telnet-server

Telnet n'est ni démarré ni activé. Il convient donc de le démarrer et de l'activer :

[root@centos8 ~]# systemctl status telnet.socket
● telnet.socket - Telnet Server Activation Socket
   Loaded: loaded (/usr/lib/systemd/system/telnet.socket; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:telnetd(8)
   Listen: [::]:23 (Stream)
 Accepted: 0; Connected: 0;

[root@centos8 ~]# systemctl start telnet.socket

[root@centos8 ~]# systemctl status telnet.socket
● telnet.socket - Telnet Server Activation Socket
   Loaded: loaded (/usr/lib/systemd/system/telnet.socket; disabled; vendor preset: disabled)
   Active: active (listening) since Fri 2025-11-28 09:42:52 EST; 2s ago
     Docs: man:telnetd(8)
   Listen: [::]:23 (Stream)
 Accepted: 0; Connected: 0;
   CGroup: /system.slice/telnet.socket

Nov 28 09:42:52 centos8.ittraining.loc systemd[1]: Listening on Telnet Server Activation Socket.

[root@centos8 ~]# systemctl enable telnet.socket
Created symlink /etc/systemd/system/sockets.target.wants/telnet.socket → /usr/lib/systemd/system/telnet.socket.

[root@centos8 ~]# systemctl status telnet.socket
● telnet.socket - Telnet Server Activation Socket
   Loaded: loaded (/usr/lib/systemd/system/telnet.socket; enabled; vendor preset: disabled)
   Active: active (listening) since Fri 2025-11-28 09:42:52 EST; 43s ago
     Docs: man:telnetd(8)
   Listen: [::]:23 (Stream)
 Accepted: 0; Connected: 0;
   CGroup: /system.slice/telnet.socket

Nov 28 09:42:52 centos8.ittraining.loc systemd[1]: Listening on Telnet Server Activation Socket.

Arrêtez le service firewalld :

[root@centos8 ~]# systemctl stop firewalld

[root@centos8 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Connectez-vous ensuite via telnet sur CentOS 8 en utilisant le port 15023 de votre VM Debian 12 :

root@debian12:~# telnet localhost 15023
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Kernel 4.18.0-348.7.1.el8_5.x86_64 on an x86_64
centos8 login: trainee
Password: 
Last login: Fri Nov 28 09:45:22 from 10.0.2.46

[trainee@centos8 ~]$ pwd
/home/trainee

[trainee@centos8 ~]$ exit
logout
Connection closed by foreign host.
root@debian12:~# 

Important - Notez bien que votre communication telnet passe par le tunnel SSH.

3.6 - SCP

Introduction

La commande scp est le successeur et la remplaçante de la commande rcp de la famille des commandes remote. Il permet de faire des transferts sécurisés à partir d'une machine distante :

$ scp compte@numero_ip(nom_de_machine):/chemin_distant/fichier_distant /chemin_local/fichier_local

ou vers une machine distante :

$ scp /chemin_local/fichier_local compte@numero_ip(nom_de_machine):/chemin_distant/fichier_distant

Utilisation

Nous allons maintenant utiliser scp pour chercher un fichier sur le «serveur» :

Créez le fichier /home/trainee/scp_test :

trainee@debian12:~$ touch /home/trainee/scp_test

Récupérez le fichier scp_test en utilisant scp :

trainee@debian12:~$ scp trainee@127.0.0.1:/home/trainee/scp_test /tmp/scp_test

trainee@debian12:~$ ls /tmp/scp_test
/tmp/scp_test

LAB #4 - Mise en place d'un VPN avec OpenVPN

4.1 - Présentation

OpenVPN :

Configuration commune au client et au serveur

Installez le paquet openvpn :

root@debian12:~# apt install openvpn

Naviguez au répertoire /etc/openvpn et créez la clef partagée :

[root@centos7 ~]# cd /etc/openvpn/

root@debian12:/etc/openvpn# openvpn --genkey secret static.key

root@debian12:/etc/openvpn# cat static.key
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
77b47829a9d17aacc71b05a2bfa9bcba
e90370cc07238a5adb74ef479e87547d
fc18a69c3c5307bdc1ca27c7aa6f3a35
e09e815a27f50c28699be3af28decd3c
b319923c2fe3826c2afb41d2e0239229
fee9bc33566941e09e2f905f1bcbb59a
55cf8d535334ac46eda3f35be0b7e22b
c3261de182f7cde5cc7d756420907514
0399672d104cebee31a44ca6d89663c7
784b928e893c4d3a6e7d294e94266e1b
5a98f80f797651199069902be01d2bbd
94765d310f8d0466484a0e7cbf10bb98
d247127aa53a6c18a6def6ed73a28b69
b7d052209318057e2ccb9660fc42543b
d79dab314ecbc19a6b8936255c17d673
fb0bdc3856a034ffc3931a7d645d6d96
-----END OpenVPN Static key V1-----
root@debian12:~# scp /etc/openvpn/static.key trainee@10.0.2.45:/tmp/static.key
trainee@10.0.2.45's password: 
static.key                                                                                                                                                                      100%  636     1.2MB/s   00:00

Configuration du client

root@debian12:/etc/openvpn# ssh -l trainee 10.0.2.45
trainee@10.0.2.45's password: trainee
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Fri Nov 28 09:47:05 2025 from ::ffff:10.0.2.46

[trainee@centos8 ~]$ su -
Password: fenestros
[root@centos8 ~]# dnf install epel-release
[root@centos8 ~]# dnf install openvpn
[root@centos8 ~]# mv /tmp/static.key /etc/openvpn
[root@centos8 ~]# ls /etc/openvpn
client  server  static.key

Créez le fichier /etc/openvpn/client/client.conf :

[root@centos8 ~]# vi /etc/openvpn/client/client.conf
[root@centos8 ~]# cat /etc/openvpn/client/client.conf
remote 10.0.2.46
dev tun
port 1194
proto udp
comp-lzo
ifconfig 10.0.0.2 10.0.0.1
secret /etc/openvpn/static.key

Lancez openvpn en ligne de commande et en arrière plan en spécifiant une journalisation :

[root@centos8 ~]# openvpn --config /etc/openvpn/client/client.conf > /var/log/vpn 2>&1 &
[1] 14598

Vérifiez ensuite que le socket d'openvpn soit ouvert :

[root@centos8 ~]# netstat -an | grep 1194
udp        0      0 0.0.0.0:1194            0.0.0.0:*    

Constatez ensuite la table de routage :

                            
[root@centos8 ~]# netstat -ar
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         _gateway        0.0.0.0         UG        0 0          0 ens18
10.0.0.1        0.0.0.0         255.255.255.255 UH        0 0          0 tun0
10.0.2.0        0.0.0.0         255.255.255.0   U         0 0          0 ens18
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0

Notez la présence de la route via tun0.

Constatez ensuite le montage du tunnel en regardant le contenu du fichier de journalisation /var/log/vpn :

[root@centos7 ~]# tail /var/log/vpn

L'architecture réseau sera donc la suivante :

                                   serveur <------------Votre réseau-------------> client
                                      |                                               |
                                      |                                               |
                                  eth0@ifxxx                                      eth0@ifxxx
                                  172.yy.0.3                                      172.yy.0.4 

Configuration du serveur

Créez le fichier /etc/openvpn/server/server.conf :

root@debian12:~# vi /etc/openvpn/server/server.conf

root@debian12:~# cat /etc/openvpn/server/server.conf
dev tun
ifconfig 10.0.0.1 10.0.0.2
secret /etc/openvpn/static.key
port 1194
proto udp
user nobody
group nobody
daemon
comp-lzo
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
log /var/log/vpn
verb 1

Arrêtez le service firewalld :

root@debian12:~# systemctl stop firewalld

root@debian12:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Lancez openvpn en ligne de commande et en arrière plan en spécifiant une journalisation :

root@debian12:~# openvpn --config /etc/openvpn/server/server.conf > /var/log/vpn 2>&1 &
[1] 11644

Vérifiez ensuite que le socket d'openvpn soit ouvert :

[root@centos7 ~]# netstat -an | grep 1194
udp        0      0 0.0.0.0:1194                0.0.0.0:*    

Constatez ensuite la table de routage :

                            
[root@centos7 ~]# netstat -ar 
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Fenêtre irtt Iface
0.0.0.0         10.0.2.2        0.0.0.0         UG        0 0          0 enp0s3
10.0.0.1        0.0.0.0         255.255.255.255 UH        0 0          0 tun0
10.0.2.0        0.0.0.0         255.255.255.0   U         0 0          0 enp0s3

Constatez ensuite le montage du tunnel en regardant le contenu du fichier de journalisation /var/log/vpn :

[root@centos7 ~]# tail /var/log/vpn

Tests

Du client vers le serveur

Sur le client, utilisez la commande ping pour envoyer des paquets dans le tunnel :

[root@centos6 ~]# ping -c3 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=7.62 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=1.35 ms
64 bytes from 10.0.0.1: icmp_seq=3 ttl=64 time=0.000 ms

--- 10.0.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2047ms
rtt min/avg/max/mdev = 0.000/2.994/7.629/3.323 ms

Du serveur vers le client

Sur le serveur, utilisez la commande ping pour envoyer des paquets dans le tunnel :

[root@centos7 ~]# ping -c5 10.0.0.2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=2.59 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=9.08 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=7.24 ms
64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=7.03 ms
64 bytes from 10.0.0.2: icmp_seq=5 ttl=64 time=4.08 ms

--- 10.0.0.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4034ms
rtt min/avg/max/mdev = 2.597/6.008/9.084/2.340 ms

Copyright © 2025 Hugh Norris.