Key-based authentication allows GitLab users to identify their device once on their account and avoid having to log in via their credentials every time. GitLab uses SSH protocol to communicate with Git.
SSH uses a public and a private key. The public key must be registered to GitLab, make sure you **do not upload your private key**.
SSH uses a public and a private key:
- The public key must be registered in GitLab, where it "identifies" your device.
- The private key must stay secret and preferably you should only keep it on a single device. This is because the private key is the only key that can be used to authenticate your identity against the public key uploaded to GitLab -- if it becomes public, everyone could impersonate your identity and thus use your GitLab account. **Make sure you do not upload the private key anywhere by accident, not even to GitLab.**
# Prerequisites
To use SSH one of the following must be installed:
To use SSH, one of the following must be installed on your device:
- The OpenSSH client, which comes pre-installed on GNU/Linux, macOS, and Windows 10.
- SSH version 6.5 or later. Earlier versions used an MD5 signature, which is not secure.
...
...
@@ -30,7 +32,7 @@ ssh -V
# Key Generation
1.Run the terminal
1.Start a terminal
2. Type the following command at the command prompt and run it after replacing your firstname and lastname:
```
...
...
@@ -40,7 +42,7 @@ ssh -V
4. Press `Enter` to continue. Defining a password is not necessary
5. To copy the contents of your public key file, run the following command:
5. To copy the contents of your public key file into the clipboard, run the following command:
- For macOS:
```
...
...
@@ -53,11 +55,11 @@ ssh -V
# Saving the SSH Key on GitLab
Once the content of the public key is copied, it must be saved to your GitLab account.
Once the content of the public key is copied in the clipboard, you need to register it with your GitLab account.