First of all check if the system already has a SSH key:
-
Windows command line:
type %userprofile%\.ssh\id_rsa.pub
-
Linux command:
cat ~/.ssh/id_rsa.pub
To generate a new SSH key:
ssh-keygen -t rsa -C "your-email@domain.com"
When prompted for the location, just press enter to use the default. If you use a different name, the key will not be used automatically.
It's a best practice to use a password for an SSH key. To change the password for your key:
ssh-keygen -p <keyname>
- Login to GitLab, click on the avatar icon on the upper right corner and go to Profile settings.
- Navigate so SSH Keys tab.
- Paste the public key generated on first step in the 'Key' box
- Optionally give a descriptive title
- Click Add key button