« Mettre en place SSH pour Gitlab/en » : différence entre les versions
Page créée avec « The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide. » |
Page créée avec « {{Attention|Cette commande génère deux fichiers dans le dossier <code>C:\Users\<ton_nom>\.ssh</code> : la clé privée (<code>id_ed25519</code>) et la clé publique (<code>id_ed25519.pub</code>). '''DO NOT SHARE THE PRIVATE KEY'''. It's the '''public key''' which should be added to Gitlab. We cannot stress enough this point. All the security counts on the fact that the private key stays secret.}} » |
||
| (5 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 4 : | Ligne 4 : | ||
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide. | The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide. | ||
The setup is relatively simple. Follow carefully the following steps. | |||
= Prérequis = | = Prérequis = | ||
Before you start, make sure you have [[Git|git]] installed on your computer. To check this: | |||
* open a cmd or PowerShell terminal (press the Windows key + R, then type <code>cmd</code> or <code>powershell</code>); | |||
* | * type <code>git -v</code> and check that Git is installed; if it isn’t, [https://git-scm.com/downloads install Git here]; | ||
* | * then type <code>ssh -V</code> to check that SSH is installed; if it isn’t, [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse install OpenSSH here]. | ||
* | |||
= Mise en place = | = Mise en place = | ||
| Ligne 23 : | Ligne 17 : | ||
== Étape 1 : Générer une clé SSH == | == Étape 1 : Générer une clé SSH == | ||
Open a terminal (cmd or powershell) and type the following command: | |||
<syntaxhighlight lang="bash">ssh-keygen -t ed25519 -C "ordi portable vaneau"</syntaxhighlight> | <syntaxhighlight lang="bash">ssh-keygen -t ed25519 -C "ordi portable vaneau"</syntaxhighlight> | ||
Replace <code>ordi portable vaneau</code> with a name of your choice. You can leave the other fields empty by pressing <code>Enter</code> for each option. | |||
Please note that there is an option to change the key’s name (by default <code>id_ed25519</code>) and the save location. There is also another option to add a passphrase to the key, which is recommended if your hard drive is not encrypted. | |||
{{Attention|Cette commande génère deux fichiers dans le dossier <code>C:\Users\<ton_nom>\.ssh</code> : la clé privée (<code>id_ed25519</code>) et la clé publique (<code>id_ed25519.pub</code>). '''DO NOT SHARE THE PRIVATE KEY'''. It's the '''public key''' which should be added to Gitlab. We cannot stress enough this point. All the security counts on the fact that the private key stays secret.}} | |||
{{Attention|Cette commande génère deux fichiers dans le dossier <code>C:\Users\<ton_nom>\.ssh</code> : la clé privée (<code>id_ed25519</code>) et la clé publique (<code>id_ed25519.pub</code>). ''' | |||
== Étape 2 : Ajouter la clé SSH sur Gitlab == | == Étape 2 : Ajouter la clé SSH sur Gitlab == | ||
Dernière version du 11 août 2026 à 11:52
The aim of this guide is to help you set up a computer to use GitLab with SSH authentication. It is aimed at beginners: for a more general introduction, see the main page on SSH and the BR’s advanced tips.
The installation steps for Windows 10 and 11 are described below. For Linux and macOS, please also refer to the main SSH guide.
The setup is relatively simple. Follow carefully the following steps.
Prérequis
Before you start, make sure you have git installed on your computer. To check this:
- open a cmd or PowerShell terminal (press the Windows key + R, then type
cmdorpowershell); - type
git -vand check that Git is installed; if it isn’t, install Git here; - then type
ssh -Vto check that SSH is installed; if it isn’t, install OpenSSH here.
Mise en place
Étape 1 : Générer une clé SSH
Open a terminal (cmd or powershell) and type the following command:
ssh-keygen -t ed25519 -C "ordi portable vaneau"
Replace ordi portable vaneau with a name of your choice. You can leave the other fields empty by pressing Enter for each option.
Please note that there is an option to change the key’s name (by default id_ed25519) and the save location. There is also another option to add a passphrase to the key, which is recommended if your hard drive is not encrypted.
Étape 2 : Ajouter la clé SSH sur Gitlab
- Connecte-toi sur Gitlab avec tes identifiants Sigma BR ;
- Clique sur ton avatar en haut à gauche, puis sur
Preferences, puis surSSH Keys(ou va directement sur cette page) ; - Clique sur
Add new key; - Copie le contenu du fichier
C:\Users\<ton_nom>\.ssh\id_ed25519.pub(ou un autre chemin si tu as choisi un autre emplacement) en remplaçant<ton_nom>par ton nom d’utilisateur Windows et colle-le dans le champKey; - (optionnel) Supprime la date d’expiration de la clé si tu veux qu’elle reste valide indéfiniment ;
- Clique sur
Add key.
Étape 3 : Préparer SSH pour utiliser la clé
- Ouvre le dossier
C:\Users\<ton_nom>\.sshsur VSCode (ou ton éditeur de texte préféré) ; - Crée un fichier
config(sans extension) ; - Ajoute le contenu suivant :
Host gitlab.binets.fr User git IdentityFile C:\Users\<ton_nom>\.ssh\id_ed25519
En remplaçant <ton_nom> par ton nom d’utilisateur Windows.
Étape 4 : Activer l'agent SSH
Taper ssh-add -L
- Si ta clef ssh est affichée, tout va bien, tu peux passer à l'étape suivante
- Sinon, suit ces étapes :
Sur windows
- Aller dans la recherche windows et lancer
Services - Chercher OpenSSH Authentification Agent
- Double cliquer dessus et mettre :
Type de démarrage : Automatique - Appuyer sur démarrer
- Dans un terminal, faire
ssh-add
Sur Linux/Mac
Voilà une solution un peu nulle qu'il faudra refaire à chaque fois que tu redémarre ton ordi. Lance un terminal et tape :
eval `ssh-agent` ssh-add
N'hésite pas à trouver une meilleure solution et à l'écrire ici.
Étape 5 : Tester la connexion SSH
Pour tester la connexion SSH, ouvre un terminal et tape la commande suivante :
ssh -T gitlab.binets.fr
Tu devrais voir un message comme ça :
The authenticity of host 'gitlab.binets.fr (129.104.201.46)' can't be established. ED25519 key fingerprint is SHA256:sn+wsip9OTBcwiY0ZplULWXNij3v3kdj/tP228i2+70. Are you sure you want to continue connecting (yes/no/[fingerprint])?
Écrit yes puis appuie sur Entrée.
Si tout s’est bien passé, tu devrais voir un message de bienvenue de Gitlab. Dans le cas contraire, vérifie que tu as bien suivi toutes les étapes précédentes. Si tu rencontres des difficultés, n’hésite pas à demander de l’aide au Binet Réseau en permanence ou sur PaniX.
Étape 6 : Configurer l’identité Git
Pour finir, il faut configurer correctement ton identité sur Git. Dans ton terminal, tape les commandes suivantes :
git config --global user.name "<Ton Nom>"
git config --global user.email "<ton.nom>@polytechnique.edu"
En remplaçant <Ton Nom> par ton nom et <ton.nom>@polytechnique.edu par les valeurs adéquates.
Félicitations ! À partir de là, tu peux utiliser Gitlab avec une authentification SSH.
Lorsque tu clones un dépôt, veille bien à choisir le lien SSH et non HTTPS.

