Présentation:
Analogie simple :
- Mot de passe = frapper à la porte et donner un mot → vulnérable (écoute, devinette)
- Clé SSH = serrure à double clé : une clé privée (gardée secrète, comme votre clé de maison) et une clé publique (le cadenas qu’on donne à qui veut vous laisser entrer)
Points clés à expliquer :
- Asymétrie : ce qui est chiffré avec la clé publique ne peut être déchiffré qu’avec la privée (et inversement pour la signature)
- La clé publique ne craint rien à être partagée (GitHub, serveur, etc.)
- La clé privée ne sort JAMAIS de la machine (protégée par une passphrase)
- Formats : RSA (legacy), Ed25519 (recommandé aujourd’hui), ECDSA
Les fichiers
etudiant@ordi:~$ ls
Arduino Documents Modèles Public Téléchargements Works
Bureau Images Musique Softs Vidéos snap
etudiant@ordi:~$ ls .ssh/
authorized_keys id_ed25519 id_ed25519.pub known_hosts
etudiant@ordi:~$ ls ~/.ssh/
authorized_keys id_ed25519 id_ed25519.pub known_hosts
etudiant@ordi:~$
id_ed25519 : clé privée (ne jamais dévoiler)
id_ed25519.pub : clé publique (à partager)
known_hosts : Clés publiques des serveurs déjà visités par cette machine (= les « visités »), hôtes connus
authorized_keys : Clés publiques d’utilisateurs autorisés à se connecter sur la machine locale.
ssh-keygen
ssh-keygen est l’utilitaire en ligne de commande du paquet OpenSSH qui sert à générer, inspecter, modifier et convertir les clés cryptographiques utilisées par SSH. C’est l’outil qui crée la paire clé privée / clé publique, et qui permet ensuite de gérer sa passphrase, son format, son empreinte, etc.
ici on utilise un répertoire test_ssh et des fichiers test_ssh avec l’option -f (file) -N « » pour aucun mot de passe pour simplifier.
si on ne précise pas l’option -f le résultat va directement dans ~/.ssh => id_ed25519.pub et id_ed25519
wb2g1app14@ordi:~$ mkdir test_ssh
wb2g1app14@ordi:~$ ssh-keygen -t ed25519 -f test_ssh/test_ssh -N "" -C "demo@ecole.fr"
Generating public/private ed25519 key pair.
Your identification has been saved in test_ssh/test_ssh
Your public key has been saved in test_ssh/test_ssh.pub
The key fingerprint is:
SHA256:KSmVW2F3v6Q0zSnAIfJBcplGN11zrlBuJZZSmPNEcgI demo@ecole.fr
The key's randomart image is:
+--[ED25519 256]--+
| ooO+E++*X.o|
| B+*.+*@oB |
| o.o ==O .|
| . + . . B.o |
| . + S . o |
| . . |
| |
| |
| |
+----[SHA256]-----+
wb2g1app14@ordi:~$
le randomart (en vert) représentation graphique de l’empreinte
la clé publique
wb2g1app14@ordi:~$ cat ~/test_ssh/test_ssh.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINnyCbVuFh40oDvCj0mbpZBK6YsQvmKPm3a8Hiqs8Ywc demo@ecole.fr
wb2g1app14@ordi:~$
une autre façon d’utiliser ssh-keygen avec les options -lf
wb2g1app14@ordi:~$ cat ~/test_ssh/test_ssh.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINnyCbVuFh40oDvCj0mbpZBK6YsQvmKPm3a8Hiqs8Ywc demo@ecole.fr
wb2g1app14@ordi:~$ ssh-keygen -lf test_ssh/test_ssh.pub
256 SHA256:KSmVW2F3v6Q0zSnAIfJBcplGN11zrlBuJZZSmPNEcgI demo@ecole.fr (ED25519)
wb2g1app14@ordi:~$
la clé : (fingerprint)
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINny...8Ywc demo@ecole.fr
└─────┬────┘ └──────────────┬───────────────┘ └─────┬─────┘
algorithme clé publique (base64) commentaire (-C)
un hash de la clé publique
L’empreinte décrit la personne, mais ne permet pas de la reconstruire. On peut l’afficher au tableau sans risque.
256 SHA256:KSmVW2F3v6Q0zSnAIfJBcplGN11zrlBuJZZSmPNEcgI demo@ecole.fr (ED25519)
└┬┘ └──────────────────────┬────────────────────────┘ └─────┬─────┘ └───┬───┘
taille empreinte (hash SHA256) commentaire type
(en bits) (lu dans le .pub)
wb2g1app14@ordi:~$ cat ~/test_ssh/test_ssh.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINnyCbVuFh40oDvCj0mbpZBK6YsQvmKPm3a8Hiqs8Ywc demo@ecole.fr
wb2g1app14@ordi:~$ ssh-keygen -lf test_ssh/test_ssh.pub
256 SHA256:KSmVW2F3v6Q0zSnAIfJBcplGN11zrlBuJZZSmPNEcgI demo@ecole.fr (ED25519)
wb2g1app14@ordi:~$
🔑 Le point crucial : le fingerprint est un hash
Trois propriétés qui expliquent tout :
Irréversible → on ne peut pas retrouver la clé à partir de l'empreinte.
Déterministe → même clé ⇒ toujours même empreinte.
Discriminant → deux clés différentes ⇒ empreintes différentes (avec une probabilité écrasante).
👉 C'est pour ça que l'empreinte est l'outil de vérification : GitHub/GitLab l'affichent quand vous ajoutez une clé, et vous pouvez comparer avec la vôtre sans jamais partager la clé complète.
la clé publique peut être régénérée à partir de la clé privée. avec l’option -y
wb2g1app14@ordi:~$ rm test_ssh/test_ssh.pub # on perd la clé publique !!
wb2g1app14@ordi:~$ ssh-keygen -y -f test_ssh/test_ssh > test_ssh/test_ssh.pub
wb2g1app14@ordi:~$ cat test_ssh/test_ssh.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINnyCbVuFh40oDvCj0mbpZBK6YsQvmKPm3a8Hiqs8Ywc demo@ecole.fr
wb2g1app14@ordi:~$ # on a retrouvé la clé publique !! OUF
refaire le randomart -lv
wb2g1app14@ordi:~$ ssh-keygen -lv -f ~/test_ssh/test_ssh.pub
256 SHA256:KSmVW2F3v6Q0zSnAIfJBcplGN11zrlBuJZZSmPNEcgI demo@ecole.fr (ED25519)
+--[ED25519 256]--+
| ooO+E++*X.o|
| B+*.+*@oB |
| o.o ==O .|
| . + . . B.o |
| . + S . o |
| . . |
| |
| |
| |
+----[SHA256]-----+
wb2g1app14@ordi:~$
la passphrase , ce qui est plus que conseillée , on utilise plus l’option -N « »
wb2g1app14@ordi:~$ ssh-keygen -t ed25519 -f ~/test_ssh/cle_protegee -C "caroline@dorian.fr"
Generating public/private ed25519 key pair.
Enter passphrase for "/home/wb2g1app14/test_ssh/cle_protegee" (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/wb2g1app14/test_ssh/cle_protegee
Your public key has been saved in /home/wb2g1app14/test_ssh/cle_protegee.pub
The key fingerprint is:
SHA256:BTw6EeCZgOwWCj6QvT35k0E7MTQt0EQEEYE5gewcgbE caroline@dorian.fr
The key's randomart image is:
+--[ED25519 256]--+
|=B++B&B+. |
|B*=o oB.+. |
|E o++o B .. |
|.B. + * . |
|. . o =S |
| + |
| . |
| |
| |
+----[SHA256]-----+
wb2g1app14@ordi:~$ ls test_ssh/
cle_protegee cle_protegee.pub
wb2g1app14@ordi:~$
ici j’ai mis la passphrase : test123
wb2g1app14@ordi:~$ ls test_ssh/ # la clé publique a disparu ! (fais exprès) rm test_ssh/cle_protegee.pub
cle_protegee
wb2g1app14@ordi:~$ ssh-keygen -lf ~/test_ssh/cle_protegee
256 SHA256:BTw6EeCZgOwWCj6QvT35k0E7MTQt0EQEEYE5gewcgbE no comment (ED25519)
wb2g1app14@ordi:~$ ls test_ssh/ # la clé publique a disparu ! (fais exprès) rm test_ssh/cle_protegee.pub
cle_protegee
wb2g1app14@ordi:~$ ssh-keygen -y -f ~/test_ssh/cle_protegee > test_ssh/cle_protegee.pub
Enter passphrase for "/home/wb2g1app14/test_ssh/cle_protegee":
wb2g1app14@ordi:~$ ls test_ssh/
cle_protegee cle_protegee.pub
wb2g1app14@ordi:~$
Et la pour re-générer la clé publique il faut la passphrase
Modifier la passphrase , option -p
wb2g1app14@ordi:~$ ssh-keygen -p -f test_ssh/cle_protegee
Enter old passphrase:
Key has comment 'caroline@dorian.fr'
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
wb2g1app14@ordi:~$
on peut vérifier la passphrase
wb2g1app14@ordi:~$ ssh-keygen -yf test_ssh/cle_protegee
Enter passphrase for "test_ssh/cle_protegee":
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINpDtfNjAEbJxrVYjRRGbw4R7QZTPb1COzZoHoZyJeXW caroline@dorian.fr
wb2g1app14@ordi:~$
la clé privée ne doit jamais être diffusée !
⚠️ Règle d’or : la clé privée (id_ed25519, cle_protegee) ne sort JAMAIS de la machine, ne se montre JAMAIS, ne se copie JAMAIS sur un serveur. Seule la .pub se partage.
ssh-copy-id
permet de copier la clé publique dans le fichier authorized_keys de l’hôte (ici wb2g1app14)
actuellement il n y même pas ~/.ssh
Depuis le client qui veut s’identifier avec sa clé publique.
bruno@debian13:~$ cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGTbNRQe9/l24i2guzpxqNkKknRMSVT/WYTTsCT+zkK1 ciela2@workboot.fr
bruno@debian13:~$
bruno@debian13:~$ ssh-copy-id -p 74 wb2g1app14@workboot.freeboxos.fr
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/bruno/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
wb2g1app14@workboot.freeboxos.fr's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh -p 74 'wb2g1app14@workboot.freeboxos.fr'"
and check to make sure that only the key(s) you wanted were added.
bruno@debian13:~$
sur l’hôte maintenant :
wb2g1app14@ordi:~/.ssh$ cat authorized_keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGTbNRQe9/l24i2guzpxqNkKknRMSVT/WYTTsCT+zkK1 ciela2@workboot.fr
wb2g1app14@ordi:~/.ssh$
on pouvait copier cette clé dans ce fichier , mais la fonction le fait parfaitement.
maintenant on peut se connecter sans donner le mot de passe de l’utilisateur wb2g1app14 à partir de la machine debian13 et en tant que bruno . C’est encore plus sécurisé que devoir redonner un mot de passe.
bruno@debian13:~$ ssh -p 74 wb2g1app14@workboot.freeboxos.fr
Last login: Tue Oct 20 18:11:41 CEST 2026 from 192.168.1.254 on ssh
╔═══════════════════════════════════════════════════════════════╗
║ ║
║ // __ __ _ _ _ ║
║ // \ \ / /__ _ __| | _| |__ ___ ___ | |_ ║
║// \ \ /\ / / _ \| '__| |/ / '_ \ / _ \ / _ \| __| ║
║\\ \ V V / (_) | | | <| |_) | (_) | (_) | |_ ║
║ \\ \_/\_/ \___/|_| |_|\_\_.__/ \___/ \___/ \__| ║
║ \\ ║
║ ║
║ Bienvenue sur le serveur Workboot ║
║ ║
║ Lycée Caroline Dorian ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
Bonjour et bienvenue sur ton espace de travail !
Tu disposes ici d'un espace personnel sur Workboot, accessible
depuis Windows, Linux ou macOS via SSH.
Ton espace est limité à 500 Mo (avertissement) et 600 Mo (blocage).
Pense à nettoyer régulièrement tes fichiers volumineux.
Pour changer ton mot de passe à tout moment : tape simplement
passwd
et suis les instructions.
Last login: Tue Oct 20 09:29:11 2026 from 192.168.1.254
wb2g1app14@ordi:~$
ssh
ici on utilise ssh avec la clé publique du client est connue de l’hôte (ssh-copy-id)
usage classique en terminal
bruno@debian13:~$ ssh -p 74 wb2g1app14@workboot.freeboxos.fr
Last login: Wed Oct 21 08:57:57 CEST 2026 from 192.168.1.254 on ssh
╔═══════════════════════════════════════════════════════════════╗
║ ║
║ // __ __ _ _ _ ║
║ // \ \ / /__ _ __| | _| |__ ___ ___ | |_ ║
║// \ \ /\ / / _ \| '__| |/ / '_ \ / _ \ / _ \| __| ║
║\\ \ V V / (_) | | | <| |_) | (_) | (_) | |_ ║
║ \\ \_/\_/ \___/|_| |_|\_\_.__/ \___/ \___/ \__| ║
║ \\ ║
║ ║
║ Bienvenue sur le serveur Workboot ║
║ ║
║ Lycée Caroline Dorian ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
Bonjour et bienvenue sur ton espace de travail !
Tu disposes ici d'un espace personnel sur Workboot, accessible
depuis Windows, Linux ou macOS via SSH.
Ton espace est limité à 500 Mo (avertissement) et 600 Mo (blocage).
Pense à nettoyer régulièrement tes fichiers volumineux.
Pour changer ton mot de passe à tout moment : tape simplement
passwd
et suis les instructions.
Last login: Wed Oct 21 08:55:25 2026 from 192.168.1.254
wb2g1app14@ordi:~$
verbose l’option -v (debug)
bruno@debian13:~$ ssh -v -p 74 wb2g1app14@workboot.freeboxos.fr
debug1: OpenSSH_10.0p2 Debian-7+deb13u4, OpenSSL 3.5.7 9 Jun 2026
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/20-systemd-ssh-proxy.conf
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to workboot.freeboxos.fr [2a01:e34:ec42:770::1] port 74.
debug1: connect to address 2a01:e34:ec42:770::1 port 74: Connection refused
debug1: Connecting to workboot.freeboxos.fr [78.196.32.119] port 74.
debug1: Connection established.
debug1: identity file /home/bruno/.ssh/id_rsa type -1
debug1: identity file /home/bruno/.ssh/id_rsa-cert type -1
debug1: identity file /home/bruno/.ssh/id_ecdsa type -1
debug1: identity file /home/bruno/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/bruno/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/bruno/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/bruno/.ssh/id_ed25519 type 3
debug1: identity file /home/bruno/.ssh/id_ed25519-cert type -1
debug1: identity file /home/bruno/.ssh/id_ed25519_sk type -1
debug1: identity file /home/bruno/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/bruno/.ssh/id_xmss type -1
debug1: identity file /home/bruno/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_10.0p2 Debian-7+deb13u4
debug1: Remote protocol version 2.0, remote software version OpenSSH_10.2p1 Ubuntu-2ubuntu3.8
debug1: compat_banner: match: OpenSSH_10.2p1 Ubuntu-2ubuntu3.8 pat OpenSSH* compat 0x04000000
debug1: Authenticating to workboot.freeboxos.fr:74 as 'wb2g1app14'
debug1: load_hostkeys: fopen /home/bruno/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: mlkem768x25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:Lo7+clRof3Ls12T38ftbcuk5LI7CbFRCAKbNsX2Rfno
debug1: load_hostkeys: fopen /home/bruno/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '[workboot.freeboxos.fr]:74' is known and matches the ED25519 host key.
debug1: Found key in /home/bruno/.ssh/known_hosts:55
debug1: ssh_packet_send2_wrapped: resetting send seqnr 3
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: Sending SSH2_MSG_EXT_INFO
debug1: expecting SSH2_MSG_NEWKEYS
debug1: ssh_packet_read_poll2: resetting read seqnr 3
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256>
debug1: kex_ext_info_check_ver: publickey-hostbound@openssh.com=<0>
debug1: kex_ext_info_check_ver: ping@openssh.com=<0>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256>
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: /home/bruno/.ssh/id_rsa
debug1: Will attempt key: /home/bruno/.ssh/id_ecdsa
debug1: Will attempt key: /home/bruno/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/bruno/.ssh/id_ed25519 ED25519 SHA256:GQT4Km5nqRYaviCcQJyxtbvNu+J0+m4c1sGYDZQrow8
debug1: Will attempt key: /home/bruno/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/bruno/.ssh/id_xmss
debug1: Trying private key: /home/bruno/.ssh/id_rsa
debug1: Trying private key: /home/bruno/.ssh/id_ecdsa
debug1: Trying private key: /home/bruno/.ssh/id_ecdsa_sk
debug1: Offering public key: /home/bruno/.ssh/id_ed25519 ED25519 SHA256:GQT4Km5nqRYaviCcQJyxtbvNu+J0+m4c1sGYDZQrow8
debug1: Server accepts key: /home/bruno/.ssh/id_ed25519 ED25519 SHA256:GQT4Km5nqRYaviCcQJyxtbvNu+J0+m4c1sGYDZQrow8
Authenticated to workboot.freeboxos.fr ([78.196.32.119]:74) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: client_input_hostkeys: searching /home/bruno/.ssh/known_hosts for [workboot.freeboxos.fr]:74 / (none)
debug1: client_input_hostkeys: searching /home/bruno/.ssh/known_hosts2 for [workboot.freeboxos.fr]:74 / (none)
debug1: client_input_hostkeys: hostkeys file /home/bruno/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: host key found matching a different name/address, skipping UserKnownHostsFile update
debug1: Remote: /home/wb2g1app14/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/wb2g1app14/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Sending environment.
debug1: channel 0: setting env COLORTERM = "truecolor"
debug1: channel 0: setting env LANG = "fr_FR.UTF-8"
debug1: pledge: fork
Last login: Tue Oct 20 18:19:53 CEST 2026 from 192.168.1.254 on ssh
on peut voir qu’il se passe pas mal de choses !!
avec ssh on peut juste faire une commande
on peut exécuter une commande à distance avec ssh , un exemple est plus clair
bruno@debian13:~$ ssh -p 74 wb2g1app14@workboot.freeboxos.fr 'ls -la'
total 32
drwx------ 4 wb2g1app14 wb2g1app14 4096 Oct 21 08:56 .
drwxr-xr-x 90 root root 4096 Oct 8 09:37 ..
-rw------- 1 wb2g1app14 wb2g1app14 379 Oct 21 08:56 .bash_history
-rw-r--r-- 1 wb2g1app14 wb2g1app14 392 Oct 4 19:22 .bash_logout
-rw-r--r-- 1 wb2g1app14 wb2g1app14 4049 Oct 4 19:26 .bashrc
drwx------ 2 wb2g1app14 wb2g1app14 4096 Oct 21 08:56 .cache
-rw------- 1 wb2g1app14 wb2g1app14 20 Oct 19 18:13 .lesshst
drwx------ 2 wb2g1app14 wb2g1app14 4096 Oct 20 18:11 .ssh
bruno@debian13:~$
un autre exemple :
bruno@debian13:~$ echo $USER
bruno
bruno@debian13:~$ ssh -p 74 wb2g1app14@workboot.freeboxos.fr 'echo $USER'
wb2g1app14
bruno@debian13:~$
