Skip to content

Instantly share code, notes, and snippets.

@lorenadl
Last active February 22, 2024 18:06
Show Gist options
  • Save lorenadl/a064c94ef9ee1193074c603bfe2e35fc to your computer and use it in GitHub Desktop.
Save lorenadl/a064c94ef9ee1193074c603bfe2e35fc to your computer and use it in GitHub Desktop.
[GitLab] Adding a new SSH Key in user profile

How to add a new SSH Key to GitLab

Generate the public/private key pair

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>

Add the new SSH key to GitLab

  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment