How To Create & Add SSH Access Token in GitLab ( Windows 11)

Akarsh Sharat
3 min readApr 15, 2024

--

Step 1: Download Git Bash

We need Open SSL to generate access token but downloading git bash give us full package for git and bash.
Go to below link ad download it for your OS, in this case
Downloads > Windows > 64-bit Git for Windows Setup.

https://git-scm.com/downloads

> Run setup as administrator then click yes
> Click Install
> Leave everything at default and click next
> Click Install
> Check Run Git bash & Click Finish

Just to be sure that open-ssl is installed in git bash type this command

openssl -version

Output will be something like :
OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)

Step 2 : Generating SSH Token

In Git Bash

ssh-keygen -t rsa -b 2048 -C "comment"

-t rsa : type of key generation ( other options )
-b 2048: Key size bits (2048 is widely recommended)
-c “comment” : This is to help identify the key ( I prefer to write email address here)
next it will ask to enter passphrase, if not needed just leave it empty and press enter

 ssh-keygen -t rsa -b 2048 -C "gitlab123@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/<userName>/.ssh/id_rsa): <Leave Empty>
Enter passphrase (empty for no passphrase): <Leave empty>
Enter same passphrase again: <Leave empty>
Your identification has been saved in test
Your public key has been saved in test.pub
The key fingerprint is:
SHA256:ZB0buXmx9SlR8roT1pJpcaT6Co6ELv/w1nkgP9S4+t8 akarshsharat123@gmail.com
The key's randomart image is:
+---[RSA 2048]----+
| o. ..o |
| ..+..* |
| o oo *.+.|
| o o +.B..|
| S oo O.. |
| .. + .+ + |
| o .=.+ + |
| .. +.o*..o . |
| ooo=oo+o E |
+----[SHA256]-----+

Then copy the path where the key is saved from above .You can locate the path to where the key is saved by checking the line-
* Enter file in which to save the key (/c/Users/<userName>/.ssh/id_rsa): *

 ls /c/Users/<userName>/.ssh/

Output :

cat /c/Users/<userName>/.ssh/id_rsa.pub

Output :

Copy this text starting from ssh-rsa , this is your ssh token

Step 3 : Add SSH Token in GitLab

> Login to GitLab
> Click on you profile picture present at left menu bar
>From dropdown Click Edit Profile

> Click on SSH Key from side menu
> Click on Add New Token ( Right side )
> You will see this page

> Key: Paste the SSH key we copied earlier in this section
> Title: Give it a title so that you can identify this key
> Usage type : Choose your usage type
> Expiration date: The key becomes invalid after this ddate but you can renew this after this date or create new key.

> Add Key
> Again go to SSH key Section

You will see Your SSH Key is added successfully. This can be used to access Gitlab from your windows.

--

--

Akarsh Sharat
0 Followers

Tech enthusiast, Tired of endless document searches? Me too. Documenting my tech journeys to simplify your tech dilemmas.