GitHub, SSH and Windows

GitHub , Windows Add comments

As part of scratching my itch to learn Ruby I decided to create a GitHub repository for storing my code, downloaded samples and koans.  Being mainly a Subversion user I decided to use GitHub for this, simply to extend my knowledge of this popular version control system.

When setting up GitHub using the detailed instructions here I ran into an issue when testing my SSH Connection, which GitHub uses to enable secure communications between your computer and the server.  Using GitBash I entered the following command:

$ ssh -T git@github.com

$ Permission denied (publickey).

I resorted to the documentation and found the following command:

$ ssh -vT git@github.com

Using the switch -vT instructs the terminal to show debug details.  Upon reviewing this debug I noticed that the session connected successfully but when trying to authenticate with my generated public key, the files being searched for where not the same as the name I created for mines.

OpenSSH was searching the .ssh folder for one of the following public key file names:

  • identity
  • id_rsa
  • id_dsa

To resolve this issue - I renamed the key files to id_rsa which resolved this issue for me.  There were two in the .ssh directory (id_rsa.pub and id_rsa).

So when creating an ssh key, when asked to enter a file in which to save the key - simply hit "Enter" and it will use the default settings.

HTH.

Bookmark and Share

3 responses to “GitHub, SSH and Windows”

  1. Jason Dean Says:
    You could also solve this using ssh-add to add the keys that you do have. For example, my github keys are called github_rsa

    ssh-add ~/.ssh/github_rsa

    It then prompts me for the passphrase for that private key and hence forth ssh will use that one as well.
  2. Niall O'Doherty Says:
    Nice tip Jason. Thanks for adding that!
  3. Ethan J Brown Says:
    A simpler fix is to make sure that there is a ~/.ssh/config file containing the following. This instructs SSH to use the default generated key names with any github.com host.

    Host *github.com
    IdentityFile ~/.ssh/github_rsa
    User git

Leave a Reply

Leave this field empty:

Powered by Mango Blog. Design and Icons by N.Design Studio