Pushing a local repo to a GitHub repo which has dual-factor authentication

9

1

I'm trying to push code in my local repo (on an OS X 10.8.5 system with the GitHub app installed and logged into) to a repo I created on GitHub via their website, using the command line. Oddly, when I try to git push -u origin master, I log in with my (correct) GitHub credentials, and get fatal: Authentication failed.

I do use dual-factor authentication, but I've authenticated the machine with this issue through the GitHub application. I've also got the appropriate SSH key for this operation.

What's the cause of this issue? How can it be fixed?

Jules

Posted 2013-09-20T01:23:19.100

Reputation: 628

Answers

15

Two-factor auth generally doesn't work per machine – it works per client. When you log in to GitHub using a web browser, it's the web browser that remembers cookies with both the auth info, and the 2FA status. git does not know about that.

To push over HTTP(S), you will need to generate a secondary password ("personal access token") in GitHub's application settings page (use the "Create new token" button). Note that git can remember the "password" if you don't want to retype/paste it every time.

user1686

Posted 2013-09-20T01:23:19.100

Reputation: 283 655

GitHub support has actually gotten back to me with the same solution, which works perfectly. Thanks! – Jules – 2013-09-20T13:56:32.297