Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub authentication failing over https, returning wrong email address

Tags:

git

github

https

Initiating a push or any other action with GitHub from the command line (over https, not ssh) that calls for the username and password not only fails but, when it does, it returns

Username for 'https://github.com': username
Password for 'https://[email protected]': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/username/repository.git/'

I do not have an @github.com address. The password and username are correct.

I know I could switch to SSH and use keys but that doesn't answer why the authentication is failing over https.

like image 837
ele Avatar asked Oct 16 '22 11:10

ele


People also ask

How do I fix fatal authentication failed for HTTPS GitHub com?

The “fatal: Authentication failed” error message Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

How do I resolve a Git authentication problem?

It happens if you change your login or password of git service account (Git). You need to change it in Windows Credentials Manager too. type "Credential Manager" in Windows Search menu open it. Windows Credentials Manager->Windows Credential and under Generic Credentials edit your git password.

How do I change my Git authentication details?

git push) and enter your username. For the password you need to generate a Personal Access Token. Go to https://github.com/settings/profile select the Developer Settings on the right. Select Personal Access Token Generate new token .


2 Answers

GitHub's support determined the root of the issue right away: Two-factor authorization.

To use GitHub over the shell with https, create an OAuth token. As the page notes, I did have to remove my username and password credentials from Keychain but with osx-keychain in place, the token is stored as the password and things work exactly as they would over https without two-factor authorization in place.

like image 174
ele Avatar answered Oct 19 '22 00:10

ele


I do not have an @github.com address

You don't have to: the @ is the separator between the username:password and the domain.
It is not an email address.

A full GitHub https url would be:

# 2014:
https://username:[email protected]/username/reponame.git

# 2021+:
https://username:[email protected]/username/reponame.git

Without the token (which would then be asked on the command line), that would give:

https://[email protected]/username/reponame.git

But again, [email protected] isn't an email address, just the first part of the credentials.

Make sure the case of your username and reponame is correct: it is case-sensitive.


Since Aug. 2021, GitHub no longer accept account passwords when authenticating Git operations on GitHub.com.
Only PAT (Personal Access Token)


Note that you can store and encrypt your credentials in:

  • 2014: a .netrc.gpg (or _netrc.gpg on Windows) if you don't want to put said credentials in clear in the URL.
    See "Is there a way to skip password typing when using https://github".
  • 2021+: a credential helper called manager-core, using the Microsoft cross-platform GCM (Git Credential Manager)
like image 24
VonC Avatar answered Oct 19 '22 00:10

VonC