Git "Authentication failed for https://github.com": passwords no longer work, use a token
Fix git "fatal: Authentication failed for https://github.com/...": use a personal access token or a credential manager, clear the old saved password, or switch to SSH.
by OhSudo ·
Checked on real software: Git, GitHub · November 2026How we check
Part of a learning path:Git for everyday work
remote: Invalid username or token. Password authentication is not supported for Git operations.fatal: Authentication failed for 'https://github.com/acme/app.git/'Older Git hosting messages said it more directly: Support for password authentication was removed on August 13, 2021. GitHub no longer accepts your account password for Git over HTTPS. It wants a token, or a login through a credential manager. GitLab and Bitbucket work the same way when you use two-factor authentication.
Often you never typed a password at all. An old saved one is being sent automatically, and has to be removed first.
TL;DR
The easiest fix, with GitHub’s CLI:
gh auth logingh auth setup-gitOr create a personal access token on GitHub, and use it as the password when Git asks. If Git doesn’t ask, clear the saved password first: section 3.
1. Option A: a credential manager
A credential manager opens a browser login once, and stores a token for you. It’s the least work:
- Windows: Git for Windows includes Git Credential Manager. Nothing to install.
- macOS:
brew install --cask git-credential-manager, or use GitHub’s CLI below. - Linux: GitHub’s CLI is the simplest.
GitHub’s CLI does the same, on any system:
gh auth logingh auth setup-gitCheck what Git is set to use:
git config --show-origin --get-all credential.helper2. Option B: a personal access token
On GitHub: Settings → Developer settings → Personal access tokens. Prefer a fine-grained token, limited to the repositories you need, with Contents: Read and write to push, and an expiry date. Then use it as the password:
Username: your-github-usernamePassword: <paste the token>On GitLab, a personal access token needs the read_repository and write_repository scopes. On Bitbucket, use an API token or an app password, depending on your account.
Don’t put the token in the URL, as in https://user:token@github.com/.... It ends up in .git/config, in your shell history, and in logs. Let the credential helper store it.
3. Remove the old saved password
If Git fails without asking anything, it’s sending something it saved earlier. Remove it, and Git asks again:
printf 'protocol=https\nhost=github.com\n\n' | git credential rejectThat works with any helper. Or by hand:
- Windows: Control Panel → Credential Manager → Windows Credentials, and remove the
git:https://github.comentry. - macOS: Keychain Access, search for
github.com, and delete the internet password. - Linux with
store: delete thegithub.comline from~/.git-credentials, which keeps passwords in plain text.
4. Check the remote’s address
git remote -vA user name built into the URL, like https://olduser@github.com/..., makes Git log in as that user. A typo in the organization or repository name gives this error as well, for private repositories, since GitHub doesn’t reveal whether they exist. Fix it with:
git remote set-url origin https://github.com/acme/app.git5. Or use SSH
With an SSH key, you avoid passwords and tokens entirely:
git remote set-url origin git@github.com:acme/app.gitAdd your public key under Settings → SSH and GPG keys. If that fails, see Permission denied (publickey). The SSH Config Generator helps with several keys and accounts.
6. In CI
Pipelines shouldn’t use a person’s password or token. GitHub Actions provides GITHUB_TOKEN for the repository it runs in, and GitLab CI provides CI_JOB_TOKEN. For other repositories, use a deploy key or a token from a bot account, stored as a secret. If GITHUB_TOKEN lacks rights, see Resource not accessible by integration.
Warning
Treat a token like a password. Give it only the repositories and rights it needs, and an expiry date. If one was ever committed or pasted somewhere public, revoke it on GitHub at once: creating a new one is quick, and bots scan public code for tokens within minutes.
Shell, we have a problem!
Similar, but different: Permission denied (publickey) is the same problem over SSH. remote: Permission to acme/app.git denied to user means you’re logged in, as someone without write access. rejected (fetch first) means you’re logged in, and the remote has newer commits. detected dubious ownership is about the folder’s owner. All the everyday commands are in the Git Cheat Sheet.
Found this useful? Share it.
Found a mistake? Let us know at contact@ohsudo.com.