Getting github working in Windows

| | No TrackBacks

What a nightmare. I generated an SSH key on Windows with puttygen to submit to github but I could not get git to retrieve the code I had authored. (Somehow, I'd managed to put the initial revision up and then broken things -- perhaps with a clone using the general URL.) Using SSH -vi <key> github.com did not help -- I still got Permission denied (public key) errors.

I ended up generating the SSH key on Ubuntu, copying that into github, and confirming that I could SSH to github.com. Here were my steps:

# Generate the rsa keys
cd ~
ssh-keygen -t rsa
chmod 600 ~/.ssh/id_rsa.*
ssh-add ~/.ssh/id_rsa.pub

# Copy public key to clipboard, paste into github
cat ~/.ssh/id_rsa.pub | xclip -selection clipboard

# Test: connect to github through console
ssh -F config -vi ~/.ssh/id_rsa.pub github.com

# Actually clone the source
cd ~/src
git clone git@github.com:username/project.git

Still, I wanted to get git working on my Windows box. This web page was instructive. Once I realized that the message meant that it could not find the key and that the default location is ~/.ssh, I copied the keys to .ssh under my home directory on Windows. Doh! You get it? The tilde stands for c:\users\username on Vista and Windows 7 and c:\Documents and Settings\username in Windows 2000 and XP. It's just not a Windows convention to use tilde -- or to use directory names that start with a period. For good measure, I added a config file for that directory:

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes
  PreferredAuthentications publickey

I think that if you copy your RSA key files to C:\Program files\git\.ssh with the config file above, you can then run this command to make sure all is well:

"C:\Program files\git\bin\ssh" -vi id_rsa.pub -F config git@github.com

Ideally, you'll be asked to confirm the github.com signature, prompted for the public key's signature three times (and since you made it without a password, you'll just hit ENTER three times), and get a message that there is no shell acccess to github. I think that there will then be a known_hosts file in the .ssh directory and the keys will have been copied to ~/.ssh. Copy the config file there for good measure and you should be able to run git to push code from your source directory.




2009-06-08: I had to revisit this today. I could not connect on a Windows box because it was picking up the wrong ssh from my path. The workaround is to set the exact one desired using the environment variable, GIT_SSH.

No TrackBacks

TrackBack URL: http://www.iwebthereforeiam.com/cgi-bin/mt/mt-tb.cgi/1499

Leave a comment

Verification (needed to reduce spam):

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.32-en

About this Entry

This page contains a single entry by Hugh Brown published on June 1, 2009 2:40 AM.

Nathan's World was the previous entry in this blog.

The things I don't know about python is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.