Posts Setup SSH Key on Gitlab And Github
Post
Cancel

Setup SSH Key on Gitlab And Github

Desktop View

Image by Arief JR

Often we are is lazy to insert user & password when clone this repository from source control. the alternative is use ssh protocol to clone this repository. In here will use two platform namely is github and gitlab. Since August 13, 2021, GitHub is no longer allowing you to use your Github account password to work with Git. One easy and much more secure way of interacting with your GitHub repositories is to generate an SSH key and to close your Git repositories with SSH. With SSH you will don’t input username and password when clone the repository.

1. Create Authentication SSH-Keygen keys on local machine

Linux and Mac

You can visit this earlier post to set up ssh-keygen

Windows

Follow this link for windows

But you should install git before to next step. download git

2. Add ssh key into gitlab

Login to your gitlab account, navigate the profile » preferences. like this below:

Desktop View

Then select SSH Keys like below screenhost:

Desktop View

And copy your id_rsa.pub what you made earlier,

Desktop View

Copy to gitlab SSH Keys page

Desktop View

Save and try clone your repository with ssh.

3. Add ssh keys into github

Login to you github account, navigate the profile » settings

Desktop View

Select SSH Keys and GPG Keys

Desktop View

Click button New SSH Key

Desktop View

Like the previous stage, copy paste your value id_rsa.pub

Trick

If you have different rsa key name, you can use this command for clone, push etc.

1
GIT_SSH_COMMAND="ssh -i ~/.ssh/(your key name)" git push origin (branch)

If you have question or suggestions, comment on below

Cheers

This post is licensed under CC BY 4.0 by the author.