22 Dec 2008

Although things were working I just started getting "Permission denied (publickey)." errors while trying to push to GitHub.

The solution was to create a config file under ~/.ssh/ as outlined at the bottom of the OS X section of this page.

Here's the file I added, as per the instructions on the page, and my pushes started working again:

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

(Either that or it was a temporary hiccup with GitHub and I've fallen into an ad-hoc fallacy in thinking that the config file did the trick — it's bedtime so testing that will be for another day!)

If any git wizards have theories as to what could have caused my pushes to stop working and why this config file is necessary, I'd appreciate a quick note in the comments.

Add Your Comment

Spam Protection by WP-SpamFree

Permission denied (publickey) errors with git and GitHub on OS X

  1. Great tip, did the trick!

    Aaron Feng
  2. I also had faced same problem on Windows using msysGit. Creating a config file solved the problem. Thanks a lot !!

    Mandar Vaze
  3. I was having a similar problem on ubuntu. This worked a treat. Thanks.

    Joe
  4. I had the same problem. Commits working one day, and then not the next.

    For me, the solution was to re-run ssh-add. From the docs:
    “Note: If you don’t use the default key names, or store your keys in a different path, you will need to run ssh-add path/to/my_key so that ssh knows where to find your key.”

    I had done this previously, but somehow it must have gotten reset.

    Marc Limotte