Search code examples
bashgitsshputtyssh-keys

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?


Solution

  • 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