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 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.
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