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

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.

Comments