How to Add ssh-key to GitLab

M
1 min readJun 5, 2020

Assumption

  1. Windows OS

Tools

  1. PowerShell
  2. Git

First thing first you have to install Git for desktop by following this link : https://git-scm.com/downloads

  1. Open Powershell (in administrator privilege)
  2. Generate the ssh-key with this command
ssh-keygen -t ed25519 -C "example@gmail.com"

After that ,the ssh-key values pair will be generated and located somewhere in

C:\Users\<Computer User name>\.ssh\id_ed25519

3. copy public key text in the file id_ed25519.pub which is located at

C:\Users\<Computer User name>\.ssh\id_ed25519.pub

4. then go to gitlab.com (if you have self-hosted GitLab server then use your self-hosted GitLab server instead of gitlab.com) then navigate to settings >> SSH keys

Ficture1: Profile dashboard

5. Paste the public key to the input textarea then click “Add key”

Figure2: GitLab public key textarea

6. Done you can use this command to check whether success or not

ssh -v git@<SELF-HOSTED URL> -p <PORT>

for example,

ssh -v git@gitlab.yourcompanyapp.com -p 2222

--

--