First SSH connection#

Dans ce tuto, nous allons voir comment se connecter au serveur pour la première fois en SSH de manière sécurisée. Pour cela, pas besoin d’installer de logiciels supplémentaire, la majorité des systèmes d’exploitation ont déjà tout le nécessaire pour cette connexion 😌. Cela dit, une tisane et un espace calme peuvent s’avérer utiles dans cette aventure.

Note

Si vous êtes bloqué·e ou rencontrez un problème, la section “Demandes et Incidents” explique comment en faire part.

Connection with the terminal#

Pour effectuer cette connexion SSH, nous avons besoin d’ouvrir une fenêtre de terminal ! 🥵 Pour cela, il faut lancer sur votre ordinateur un programme qui s’appelle en général terminal ou console.

For Windows

In the case of Windows, use the program called Powershell. Since its default configuration is terrible 💩, it must be corrected with the following command:

$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'

To “paste” the text in Powershell you can do Ctrl + V, or just right click with your mouse.

Ne vous laissez pas impressionner par son interface déroutante, c’est un outil qui va faire de vous un·e véritable magicien·ne de l’informatique ! 🧙 Un peu comme des sortilèges, on y lance des commandes.

Heuuu… mais comment on lance une commande 🤨 ?

Dans un terminal, il faut taper le texte d’une commande, puis appuyer sur Entrée pour la lancer ! 🪄

Pour se connecter en SSH, on utilise la commande suivante (remplacer USER par votre identifiant CLUB1) :

ssh USER@club1.fr

You should see the following message:

The authenticity of host 'club1.fr (***)' can't be established.
ED25519 key fingerprint is SHA256:*********.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

😱 Wow! What the hell is this??

In fact, this is normal, OpenSSH warns us that the authentication of the connection is not guaranteed because your device does not know this server yet.

Replying yes to this message exposes oneself to a man-in-the-middle attack 🥸. So we’re going to answer no for now.

Trust reigns#

We will add to your device the public key of the CLUB1 server. This allows to guarantee the authenticity of the server’s answers and to initialize an encrypted connection. In this way we are certain that we are indeed dealing with the CLUB1 server.

To be sure that this is indeed the CLUB1 server’s key, it must be acquired from another source than the SSH connection itself in case it is compromised 😮.

🤔 But then, what guarantees that the new source is not also compromised?

The source of the key we are going to use comes from the Web, through an encrypted and authenticated connection via TLS 🔒 (This is the famous s in https).

known_hosts file#

Maintenant il ne nous reste plus qu’à écrire la clef du serveur dans un fichier. Les commandes suivantes font tout ça pour vous ! 🪄

mkdir -p ~/.ssh
echo 'club1.fr ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBFQJRiEKM9iywtuvjLD7Wvp6F7VqM6ocuc0Q05LGKU6' >> ~/.ssh/known_hosts

Tip

In a terminal window, it is usually possible to “paste” a text by doing “Right click” → Paste. Or Ctrl + Shift + V.

Si tout s’est bien passé, cela a ajouté une ligne de texte contenant la clef 🔑, à un fichier sur votre appareil. Ce fichier s’appelle known_hosts, serveurs connus. Il se trouve dans un dossier .ssh, lui-même au sein de votre espace personnel sur votre appareil.

Note

The folder corresponding to your personal space is usually named after your user on this device.

📁 <utilisateur>
├─ 📁 .ssh
│  └─ 📄 known_host    👈
├─ 📁 Documents
├─ 📁 Images
...

Connexion sécurisée#

Maintenant que l’on a passé toutes ces étapes, Vous devriez pouvoir vous connecter en SSH sans voir le message d’alerte.

On lance à nouveau la commande :

ssh USER@club1.fr

Cette fois ci, il vous faudra alors entrer votre mot de passe CLUB1.

Attention

When you type your password, nothing is displayed! It is normal, it is a security measure that does not even reveal the number of characters in the password. 🤫

In the server#

Congratulations 🎉, you are now connected to the server in SSH! It is a privileged access, because it is the one that gives you the most freedom of interaction with the server.

🍾 To celebrate, here is a small selection of commands to discover.