Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add an already generated SSH key to git bash?

I have an SSH key saved in D:/keys folder. I want to add it to my git bash. All the tutorials I found is how to generate SSH key using gitbash and load it to github/gitlab. I generated my SSH key using puttygen. Now I want to add it to my git bash so that I can clone a repository from remote. How can I do that?

like image 383
Samiul Alam Avatar asked Sep 11 '19 06:09

Samiul Alam


2 Answers

On windows you might need to start the ssh agent like this

# start the ssh-agent in the background
$ eval $(ssh-agent -s)
> Agent pid 59566

Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.

$ ssh-add <path/to/key>

Got this information from here under "Adding your SSH key to the ssh-agent": https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent

like image 89
Robert Engel Avatar answered Sep 22 '22 23:09

Robert Engel


I don't think there is any specific config in gitbash itself. You have to put the key in the default location ~\.ssh/id_rsa and it will be used. If you need to have it somewhere else you could do so with a config file same as on Linux ~/.ssh/config

host example.com
 HostName example.com
 IdentityFile ~/.ssh/id_rsa
 User git

Don't forget to set the permissions chmod 400 ~/.ssh/id_rsa

like image 40
arxzur Avatar answered Sep 18 '22 23:09

arxzur