Git: Authentication Failed When Pushing to GitHub

Your git push fails with 'Authentication failed' even though the password is right. GitHub stopped accepting passwords over HTTPS years ago. Here's how to use a token or SSH key instead.

BytExplorer 5 min read July 1, 2026

You push and get:

remote: Support for password authentication was removed.
fatal: Authentication failed for 'https://github.com/you/repo.git/'

Your password isn't wrong — it just isn't accepted anymore. GitHub removed password authentication for Git operations over HTTPS back in 2021. You might see it phrased as Support for password authentication was removed or Password authentication is not supported for Git operations, and changing your GitHub password won't help — passwords simply aren't accepted over HTTPS anymore. You now authenticate with either a personal access token (PAT) or an SSH key. Pick one.

Option A: Personal access token (stays on HTTPS)

Fastest if your remote is already an https:// URL.

  1. On GitHub: Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token.
  2. Give it repo (or fine-grained "Contents: read/write") access to the repo, set an expiry, and copy the token — you only see it once.
  3. Push again. When Git prompts for a password, paste the token instead:
git push
# Username: your-github-username
# Password: <paste the token, not your account password>

So you don't paste it every time, let Git remember it:

git config --global credential.helper store   # or 'osxkeychain' / 'manager'

The token is the password now. Treat it like one: give it the narrowest scope that works and an expiry date, and never commit it into a repo.

Option B: SSH key (no tokens to manage)

Better long-term if you push often.

ssh-keygen -t ed25519 -C "[email protected]"   # press Enter for defaults
cat ~/.ssh/id_ed25519.pub                     # copy this public key

Add that public key on GitHub under Settings → SSH and GPG keys, then switch your remote from HTTPS to SSH:

git remote set-url origin [email protected]:you/repo.git
ssh -T [email protected]        # test: should greet you by username
git push

The checklist

  1. The error means password auth is gone — not a typo.
  2. HTTPS remote → create a PAT, paste it as the password, cache with a credential helper.
  3. Push a lot → generate an SSH key, add the public key, switch the remote to git@.
  4. Never commit a token; scope and expire it.

Frequently Asked Questions

Why does Git say "password authentication is not supported for Git operations"? It's the same change described above, just phrased differently. GitHub (and most hosts) stopped accepting your account password over HTTPS. Authenticate with a personal access token or an SSH key instead — your password will not work again no matter how many times you re-enter it.

I changed my GitHub password and Git still fails — why? Because the problem was never your password. Password authentication for Git was removed entirely, so changing it has no effect. Create a personal access token or switch to SSH and use that instead.

Is a personal access token the same as my password? No. A PAT is a separate, revocable credential you generate on GitHub with a limited scope and an expiry date. When Git prompts for a "password" over HTTPS you paste the token there, but you can revoke it any time without touching your account password.

Should I use a personal access token or an SSH key? Use a PAT if your remote is already an https:// URL and you just want to push now. Use an SSH key if you push often or from a machine you control long-term — there is nothing to paste and nothing to expire. Both are equally valid.

How do I stop Git asking for the token every time? Cache it with a credential helper: git config --global credential.helper store (or osxkeychain on macOS, manager on Windows). With an SSH key there is no prompt at all once the key is added.

Put it into practice

Stop reading, start building

This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.

More in Troubleshooting