Wednesday, April 16, 2008

github and public key

If you haven't heard, everyone is moving to git. Not really sure why yet, I like svn, but felt like I should probably keep in touch. I have a need to create a Stage generator for Merb, so I thought this would be a good opportunity. Quick note: the Stage generator for Merb will be a refactor which I will port to Rails later.

The account setup at github was easy and I followed the directions for providing my public key. Checked and double checked.

I then added my repository and followed the following steps (also from github):
$ mkdir stage
$ cd stage
$ git init
$ touch README
$ git add README
$ git commit -m 'first commit'
$ git remote add origin git@github.com:stonean/stage.git
$ git push origin master

I get to the last step and try the push. Ooops:
$ git push origin master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
error: failed to push to 'git@github.com:stonean/stage.git'

I knew it was a configuration issue, just wasn't sure if it was a git thing or not. After a minute or two of thinking it through, all I needed to do was:
$ cd ~/.ssh
$ ssh-add id_rsa

I then re-tried the push command, and it worked. Cool.

8 comments:

greengaloshes.cc said...

This was helpful - I got stuck at the same point you did, and the ssh-add worked for me - thanks!

Anonymous said...

Didn't work for me:

$ ssh-add id_rsa
Could not open a connection to your authentication agent.

Noam said...

This worked for me, thanks!

LesFreeman said...

If anyone else gets this message:
Could not open a connection to your authentication agent.

Look here for some good advice:
http://www.cs.indiana.edu/csg/FAQ/Security/openssh.html

Andrew Stone said...

Thanks for the additional info, much appreciated.

JJ said...

Another thanks from here. Really helpful.

Julien said...

Thanks for this!
Merci pour ceci!

web architecte said...

i cant solve it, i'm new in Mac, would you see following

macmini:cake-test macmini$ git push origin master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
macmini:cake-test macmini$ cd ~/.ssh
macmini:.ssh macmini$ ssh-add id_rsa
id_rsa: No such file or directory