An SSH key is used instead of a password when authenticating to GitLab and similar services over the SSH protocol. The SSH key has two parts: The private key (secret) that only you should have and the public key that you give to any service you want to authenticate with.
You can read more about public-key cryptography on Wikipedia.
Create and add SSH Key to Windows
# In the terminal
ssh-keygen -t ed25519 -C "GitLab"
# When asking for location, press enter
# Type your password, twice (will be hidden)
Add the SSH private key to Windows (optional)
If you have activated Windows SSH, you can add the key to the Windows’ key management to avoid having to type the password every time.
# If using Command Prompt
ssh-add %USERPROFILE%\.ssh\id_ed25519
# If using PowerShell
ssh-add $env:USERPROFILE\.ssh\id_ed25519
Add the SSH public key to GitLab
You can add the SSH public key under Preferences > SSH Keys > Add new key
.
Copy the contents of your public key into the textbox labelled Key
.
You can easily find your key by running:
notepad %USERPROFILE%\.ssh\id_ed25519.pub
Test that it works
You can test that it works by running (replace the URL to your instance):
ssh -T git@gitlab.com
# Welcome to GitLab, @username!