Support for password authentication was removed: HTTPS push to GitHub
Password auth for Git over HTTPS ended in 2021. Clear the cached credential, use a token with the right scopes, and authorize it for SSO.

Introduction & Quick Summary
remote: Support for password authentication was removed on August 13, 2021.
fatal: Authentication failed for 'https://github.com/owner/repo.git/'GitHub stopped accepting an account password for Git over HTTPS. The credential is now a personal access token, a fine-grained token, an SSH key, or a GitHub App installation token, and the error appears whenever the stored credential is still a password.
Why it keeps happening after the first fix:
- A cached password is still in the credential store. Windows Credential Manager, macOS Keychain, and
~/.git-credentialseach keep the old entry and hand it back before the remote is even contacted. - The token is expired or has no repository access. Fine-grained tokens expire, and they need Contents permission on the specific repositories.
- Organization SSO is not authorized. A valid token is rejected for an org repository until the token is approved for that organization.
- CI has no terminal to prompt on.
GIT_TERMINAL_PROMPT=0or a non-interactive runner turns the same auth failure intocould not read Username.
| Message | Meaning | Fix |
|---|---|---|
Support for password authentication was removed | A password was sent | Replace the stored credential with a token |
fatal: Authentication failed for ... | Credential rejected | Check expiry, scopes, and SSO |
could not read Username for 'https://github.com' | No terminal, no credential | Provide a token in the environment |
remote: Permission to owner/repo.git denied to user | Authenticated but not authorized | Grant repo access or re-scope the token |
fatal: could not read from remote repository | Any of the above | Read the line above it |
Core Mechanics, Signatures & Reproducible Setup
HTTPS Git uses HTTP Basic authentication with a username and a secret. git asks a credential helper for host=github.com, and if the helper has nothing it prompts. Since 2021 the secret must be a token, and the token is what the Authorization header carries, base64-encoded.
A reproduction is a clone with a deliberately wrong secret:
cd /tmp && rm -rf demo
GIT_TERMINAL_PROMPT=0 git clone https://github.com/octocat/Hello-World.git demo
# fatal: could not read Username for 'https://github.com': terminal prompts disabled# the same request with a token, without writing it into shell history
read -rs GH_TOKEN
git clone "https://x-access-token:${GH_TOKEN}@github.com/owner/private-repo.git" demo
unset GH_TOKENThe working setup is almost always a credential helper plus a token created once:
gh auth login --hostname github.com --git-protocol https --web
gh auth setup-git
git config --global --get-all credential.helpergh auth setup-git registers gh as the credential helper for github.com, so git push gets a token from the same login the CLI uses.
Key Comparison Table
The four credential types differ in scope, lifetime, and where they are accepted.
| Method | Secret | Scope control | Expiry | Works for CI |
|---|---|---|---|---|
| Classic PAT | ghp_... | Checkbox scopes (repo, workflow) | Optional | Yes |
| Fine-grained PAT | github_pat_... | Per-repository, per-permission | Required, max 1 year | Yes |
| SSH key | Private key file | Per-key, deploy keys per repo | Optional | Yes |
| GitHub App token | ghs_... | Installation repositories | 1 hour | Yes |
| Account password | n/a | n/a | n/a | No, rejected |
Credential helpers decide where the secret lives and which one wins when several are configured.
| Helper | Platform | Storage | Notes |
|---|---|---|---|
manager | Windows, macOS, Linux | OS credential store | Installed with Git for Windows |
osxkeychain | macOS | Keychain | Default with Apple Git |
libsecret | Linux | Secret Service | Needs a running keyring |
store | Any | Plain file ~/.git-credentials | Readable by any process |
cache | Any | Memory, timeout | --timeout=3600 |
gh | Any | gh auth token | Set by gh auth setup-git |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
Clear the stale credential first
A helper that already holds a password keeps returning it, so a new token changes nothing until the old entry is gone.
# macOS
printf "protocol=https\nhost=github.com\n\n" | git credential-osxkeychain erase
# Windows
cmdkey /list | grep github
cmdkey /delete:git:https://github.com
# Linux with libsecret
printf "protocol=https\nhost=github.com\n\n" | git credential-libsecret erase
# any platform, plain file helper
grep -n github ~/.git-credentials# confirm which helper answered
GIT_TRACE=1 GIT_CURL_VERBOSE=0 git ls-remote https://github.com/owner/repo.git 2>&1 | grep -i credentialAfter the erase, the next git push prompts once and stores the token under the same host.
Scope and expiry for fine-grained tokens
A fine-grained token that can read the repository but not write produces an authentication failure on push while clone works, which looks like a Git problem rather than a permission one.
Repository access: Only select repositories → owner/repo
Permissions: Contents → Read and write
Metadata → Read-only (mandatory)# verify what the token can do before debugging git
curl -s -H "Authorization: Bearer $GH_TOKEN" https://api.github.com/repos/owner/repo \
| jq '{full_name, permissions}'A 403 with Resource not accessible by personal access token means the permission is missing, not the credential.
Organization SSO authorization
An organization with SAML SSO rejects tokens that have not been authorized for it. The failure is a 403 on the first fetch, and the fix is one click in the token settings, not a new token.
git ls-remote https://github.com/org/repo.git
# remote: The `org` organization has enabled or enforced SAML SSO.
# remote: You must use a personal access token with the `read:org` scope...# check SSO state through the API
curl -s -H "Authorization: Bearer $GH_TOKEN" \
https://api.github.com/orgs/org/credential-authorizations | jq '.[] | {login, credential_type, authorized}'Classic tokens need the read:org scope for the check; fine-grained tokens need the organization to approve the token.
Non-interactive CI without leaking the token
On a runner there is no terminal, so the failure is could not read Username. Two patterns avoid it: a credential helper configured in the job, or an askpass script.
# option 1: gh as the helper
gh auth setup-git
git push origin HEAD
# option 2: askpass, no token in the remote URL
export GIT_ASKPASS="$PWD/askpass.sh"
export GH_TOKEN="$(cat "$TOKEN_FILE")"#!/usr/bin/env bash
# askpass.sh
case "$1" in
*Username*) echo "x-access-token" ;;
*Password*) echo "$GH_TOKEN" ;;
esacKeeping the token out of the remote URL matters because git remote -v and git config --list are both logged by CI systems.
Switching to SSH to remove the credential entirely
SSH keys avoid token rotation and are accepted for Git over git@github.com: URLs. The trade-off is key management and an agent that must be available.
ssh-keygen -t ed25519 -C "laptop" -f ~/.ssh/id_ed25519_gh
eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_ed25519_gh
gh ssh-key add ~/.ssh/id_ed25519_gh.pub --title "laptop"git remote set-url origin git@github.com:owner/repo.git
ssh -T git@github.com
# Hi owner! You've successfully authenticated, but GitHub does not provide shell access.# ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_gh
IdentitiesOnly yesIdentitiesOnly yes stops the agent from offering other keys first, which is the usual reason an SSH push fails with Permission denied (publickey) despite a working key.
Rewrite a remote that still embeds a token
A remote URL with an embedded token keeps working until the token expires, then fails in a way that looks unrelated. Remove the token from the URL and let the helper supply it.
git remote -v
# origin https://ghp_oldtoken@github.com/owner/repo.git (fetch)
git remote set-url origin https://github.com/owner/repo.git
gh auth setup-git
git fetch originIf the token was committed to a script or workflow, rotate it rather than deleting the line; the secret is already in the history.
Common Compilation/Runtime Mistakes & Version Gotchas
Creating the token with no repo scope. Classic tokens without repo can read public repositories and nothing else. Fine-grained tokens need Contents explicitly, and Metadata is automatic.
Storing the token in the remote URL. It works until rotation, leaks through git remote -v and CI logs, and leaves the credential in every clone's config.
Using store on a shared machine. ~/.git-credentials is plaintext and readable by other local users; cache or an OS keyring is the correct choice.
Expecting a password to work for apps with 2FA. Two-factor authentication is not the issue: even with 2FA disabled, the password is refused for Git operations.
Ignoring the line above the fatal error. fatal: could not read from remote repository is a summary. The remote: line above it names the actual reason, SSO, scope, or a missing repository.
Version notes. Password authentication was removed on 2021-08-13. Fine-grained tokens became generally available in 2022 and require an expiry. gh auth setup-git exists since gh 2.0 and writes credential.https://github.com.helper entries, which take precedence over the global helper. Git 2.35 and later ship credential-manager on more platforms, so manager may be configured even if you never chose it.
Triage order: erase the stored credential, verify the token with one API call, then check the helper that answers. When a workflow file or remote config is the suspect, the env reader shows which variables the job actually has, and the base64 encoder is a quick way to inspect the Basic auth header a request would send without printing the token itself.
Official references: Managing personal access tokens and gitcredentials.
Official references
primary documentationThe Git documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Git work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Git guides
All Git guidesGit on Windows: Filename too long and the core.longpaths fix
Windows still caps many paths at 260 characters. Shorten the clone root, enable core.longpaths system-wide, and turn on the OS long path setting.
Git: gpg failed to sign the data, and why the commit is not written
No commit is created when signing fails. List the secret keys, expose a TTY, and point Git at the right gpg binary.
Git: SSL certificate problem: self-signed certificate in certificate chain
The browser trusts it and Git does not. Identify the root, keep the public bundle, and avoid the global sslVerify setting that hides the problem.
Git: error: RPC failed; HTTP 413 curl 22 on push
Curl 22 is a wrapper, the status before it is the answer. Separate the client buffer from the proxy and provider limits, then shrink the pack.
More in Git
All Git guidesThe guides filed next to this one in Git, in library order.