Kirk's PRNG

"Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin." --John von Neumann

« Back to blog

GitHub "Permission Denied (publickey)" Error Workaround

This frustrated me for 45 minutes tonight, and hopefully this post can save someone else from similar pain.

[MyRepo (master)]$ git push origin master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

I followed all the instructions at http://github.com/guides/providing-your-ssh-key and http://github.com/guides/addressing-authentication-problems-with-ssh and verified my connection was working via the ssh git@github.com command, but kept receiving the Permission Denied (publickey) error when trying to push to github. Eventually I stumbled onto a workaround. In your local repository, remove and re-add the remote link. These commands worked for me, but YMMV:

git remote rm origin
git remote add origin <remote url>

Replace the remote url with your github clone url (looks like "git@github.com:<username>/<reponame>.git") and try your push again. If it doesn't work for you, please post a comment below and let me know why and what you did instead.

May 06, 2009
Dylan Thomas said...
Try using Mercurial instead. Supported on code.google.com and written in Python. Plus it doesn't have a name that mean "tosser" in English :-)
Jan 23, 2011
Andrew said...
Thanks a bunch, man... I was also struggling with the exact same problem and removing and re-adding the remote link worked great. I actually tried re-adding it early on, but I didn't know how to remove it first.
Apr 24, 2011
Wartek said...
Thank you! I spent 1 hour tonight to resolve this problem and then I found your post here. Thank you again :)
Oct 28, 2011
FedeV said...
i'm new to github..I had the same problem..solved thanks to you! good good good!
Jan 02, 2012
Andrew said...
Thanks a lot for this! I've spent the past hour or two setting up Git, wondering why I can't get my code to upload and going through the help pages again and again for something I may have missed. This, finally, seems to have worked.