How do I add an SSH key in gitlab?

Viewed 65888

Here is what my dashboard looks like:

enter image description here

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

5 Answers

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@example.com"  
    

    Or, if you want to use RSA:

    ssh-keygen -t rsa -b 4096 -C "email@example.com"  
    

    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 git@gitlab.com:xyz/SpringBootStarter.git)

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 "mail@example.com"
   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

Related