Pushing a local repo to a GitHub repo which has dual-factor authentication
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.
Related videos on Youtube
Jules
Expert Python programmer with experience working with the Linux network stack, REST APIs, and relational databases (and Postgres in particular). There's some devops experience in there too, but software dev is my preference. Not currently open to new work.
Updated on September 18, 2022Comments
-
Jules almost 2 years
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 getfatal: 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 almost 11 yearsGitHub support has actually gotten back to me with the same solution, which works perfectly. Thanks!