Invalid username or password when try to push a commit

I am pretty new to github, and am trying to upload some files to a expository. I got as far as cloning the repo locally (well, not really locally as I am ssh’d into a remote server…), and copying a file to the cloned repo. I then used the git add . and then git commit -m 'Add existing file' commands as outlined here.

Now, when I try git push origin master I am prompted for my username and password. I enter my github username and password (which worked to log into the website), but get an error:

remote: Invalid username or password.
fatal: Authentication failed for [repository name]’
Any advice would be appreciated!

Hi @annazuckerman, welcome to the community!

Sometimes an old or incorrect username/password combination can remain stored in your local git configuration, which then causes authentication errors when trying to push. It sounds like this might be what’s happening to you.

Thankfully, you can clear saved credentials from your local git configuration by running the following three commands in the command line:

git config --unset-all credential.helper
git config --global --unset-all credential.helper
git config --system --unset-all credential.helper

The first command resets credentials at the repository level; the second at the user level; and the third at the system level. I’d suggest running all three, after which you should be prompted to re-authenticate upon your next push.

I hope this helps!

2 Likes

Thanks so much for the help!
I’m a bit concerned about doing this, as I am ssh’d into the compute nodes of my organization and I’m cautious about messing things up. I’ve also never had a different username or password (only been on github less than a year), and certainly never on the remote server for my organization. Do you still recommend those commands?
Thanks again!

Aha! :bulb: that explains something, if you are accessing an organization that uses SAML single sign-on (SSO), you must authenticate with a personal access token instead of your username and password for GitHub. Here is are the steps to create a PAT, maybe give that a go to start?

Ok, thank you! How do I tell if my organization uses SSO?
To clarify, it is my own personal github repo, and I am trying to upload a file that is in my home directory when I am ssh’d into my organization’s compute node.