GitHub Error: Authentication Failed from the Command Line

GitHub Error: Authentication Failed from the Command Line

After setting up 2 Factor Authentication on GitHub, I couldn?t push my remote repositories from the command line anymore.

When I tried to push a remote repo, the command line threw this error:

~ :> git push origin my-branchUsername for ‘https://github.com’: myusernamePassword for ‘https://[email protected]’: mypasswordremote: Invalid username or password.fatal: Authentication failed for ‘https://github.com/my-repository?

The error stumped me ? and made me vow that, when I did ultimately get to the bottom of it, I?d do my best to pay the knowledge forward.

How to Authenticate on GitHub with 2FA

Command line authentication requires a personal access token.

Go to Settings:

Image for post

Then Developer Settings:

Image for post

Then Personal access tokens:

Image for post

Generate a new Personal Access Token. Make sure you copy the Personal Access Token as soon as it gets generated ? you won?t be able to see it again!

Image for post

Paste the Personal Access Token into the ?Password? field when you authenticate via the command line.

Image for post

GitHub has published official instructions for this flow here (though without glam screenshots?)

Hope this helps ? happy coding!

17

No Responses

Write a response