Github: Invalid Username or Password

Github: Invalid Username or Password

I have a project hosted on GitHub. I fail when trying to push my modifications on the master. I always get the following error message

Password for ' 
remote: Invalid username or password.
fatal: Authentication failed for '

However, setting my ssh key to github seems ok. Indeed, when I do a ssh -T I get

Hi eurydyce! You've successfully authenticated, but GitHub does not provide shell access.

Which seems to indicate that everything is OK from that side (eurydyce being my github username). I strictly followed the instructions given on github and the recommendations of many stack discussion but no way. Would you have any idea of what I may have done wrong?

2

28 Answers

After enabling Two Factor Authentication (2FA), you may see something like this when attempting to use git clone, git fetch, git pull or git push:

$ git push origin master
Username for ' your_user_name
Password for ' 
remote: Invalid username or password.
fatal: Authentication failed for '

Why this is happening

From the GitHub Help documentation:

After 2FA is enabled you will need to enter a personal access token instead of a 2FA code and your GitHub password.

...

For example, when you access a repository using Git on the command line using commands like git clone, git fetch, git pull or git push with HTTPS URLs, you must provide your GitHub username and your personal access token when prompted for a username and password. The command line prompt won't specify that you should enter your personal access token when it asks for your password.

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.