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
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:
Then select SSH Keys like below screenhost:
And copy your
id_rsa.pub what you made earlier,
Copy to gitlab SSH Keys page
Save and try clone your repository with ssh.
3. Add ssh keys into github
Login to you github account, navigate the profile » settings
SSH Keys and GPG Keys
Click button New SSH Key
Like the previous stage, copy paste your value
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)