a53-416
a53-416

Reputation: 3935

How do I add an SSH key in gitlab?

Here is what my dashboard looks like:

enter image description here

Not really sure where to add an SSH key. Anyone have any idea?

Upvotes: 48

Views: 261106

Answers (5)

Nguyễn Hồng Sơn
Nguyễn Hồng Sơn

Reputation: 259

  1. Open the terminal and type: ssh-keygen -t rsa
  2. It will display something like this: -> Generating public/private rsa key pair. Enter file in which to save the key (C:\Users\abc/.ssh/id_rsa):
  3. Copy the path: C:\Users\abc/.ssh/id_rsa -> Enter file in which to save the key (C:\Users\sonnguyen/.ssh/id_rsa): C:\Users\sonnguyen/.ssh/id_rsa -> press Enter
  4. Enter a password and confirm the password
  5. You will see the location of the generated SSH key open in Notepad; copy this and paste it into GitLab.

Upvotes: 6

prashant.kr.mod
prashant.kr.mod

Reputation: 1682

Go to your GitLab account: https://gitlab.com/

Click on Settings on the top right drop-down, which will appear once you select the icon(white-fox image [specific to my profile]). enter image description here

Click on Settings on the top right drop-down, which will appear once you select the icon(white-fox image).

Click on SSH Keys:
enter image description here

Add/Paste the SSH Key.
How to generate the ssh key: Download gitbash or putty:

After downloading gitbash/putty follow the steps:

  1. Open a terminal on Linux or macOS, or Git Bash / WSL on Windows.
  2. Generate a new ED25519 SSH key pair:

    ssh-keygen -t ed25519 -C "[email protected]"  
    

    Or, if you want to use RSA:

    ssh-keygen -t rsa -b 4096 -C "[email protected]"  
    

    It will generate the key in => C:\Users\yourname.ssh directory.

  3. Copy the public key and paste in the gitlab location:

    enter image description here

Command to run on gitbash to clone the repository:

ssh-agent $(ssh-add C:\Users\youname\.ssh\id_rsa; git clone [email protected]:xyz/SpringBootStarter.git)

Upvotes: 57

Shabeer K
Shabeer K

Reputation: 1617

First, you need to do open terminal after that type

   mkdir -p ~/.ssh
   echo public_key_string >> ~/.ssh/authorized_keys
   chmod -R go= ~/.ssh
   chown -R shabeer:shabeer ~/.ssh
   ssh-keygen  or ssh-keygen -t ed25519 -C "[email protected]"
   xclip -sel clip < ~/.ssh/id_ed25519.pub
   ~/.ssh/gitlab_rsa.pub

in this time can see your key and copy it, After that Go to the Gitlab settings and chose SSH Keys, you can see there have to option add that copied key

Upvotes: 1

Marco van Neerbos
Marco van Neerbos

Reputation: 536

Goto https://gitlab.com/profile/keys.

If you are a new user a banner will show at the top of each project page.

You won't be able to pull or push project code via SSH until you add an SSH key to your profile

However, you can dismiss this warning.

Upvotes: 3

Oli
Oli

Reputation: 415

  1. You need to sign in. Green button top right.
  2. Click 'profile settings' on the left side menu.
  3. Click SSH Keys and follow the instructions on the page.

Upvotes: 21

Related Questions