You’re trying to push your code to GitHub and suddenly hit that dreaded authentication failed error. This happens when GitHub can’t verify who you are, blocking your push attempt entirely.
Step-by-Step Fixes
Step 1: Generate a Personal Access Token (Fastest Fix)
GitHub stopped accepting passwords for Git operations back in 2021. You need a Personal Access Token (PAT) instead. Head to GitHub.com, click your profile picture, then Settings > Developer settings > Personal access tokens > Tokens (classic). Click “Generate new token” and select these scopes:
- repo (full control)
- workflow (if you use GitHub Actions)
Copy the token immediately – you won’t see it again. When Git asks for your password, paste this token instead.
Step 2: Update Your Git Credentials
Your computer might be holding onto old credentials. On Windows, open Credential Manager from Control Panel. Look for any GitHub entries and delete them. On Mac, open Keychain Access and remove GitHub passwords. On Linux, check your credential helper with:
“`bash
git config –global credential.helper
“`
Then clear stored credentials:
“`bash
git credential-manager-core erase
“`
Try pushing again – Git will ask for your username and token.
Step 3: Switch to SSH Authentication
SSH keys offer a more permanent solution. Generate a new SSH key:
“`bash
ssh-keygen -t ed25519 -C “[email protected]”
“`
Press Enter through the prompts. Then add it to your SSH agent:
“`bash
eval “$(ssh-agent -s)”
ssh-add ~/.ssh/id_ed25519
“`
Copy your public key and add it to GitHub under Settings > SSH and GPG keys:
“`bash
cat ~/.ssh/id_ed25519.pub
“`
Step 4: Check Your Remote URL
Your repository might still use the old HTTPS format. Check with:
“`bash
git remote -v
“`
If you see https://github.com/username/repo.git, switch to SSH:
“`bash
git remote set-url origin [email protected]:username/repo.git
“`
Step 5: Enable Two-Factor Authentication Properly
If you have 2FA enabled on GitHub, regular passwords definitely won’t work. You must use either a Personal Access Token or SSH keys. PATs are ideal for HTTPS connections, while SSH keys are best used in environments where you frequently push code.
Step 6: Update Git to Latest Version
Older Git versions sometimes struggle with modern authentication. Check your version:
“`bash
git –version
“`
If you’re running anything below 2.30, update it. On Windows, download from git-scm.com. Mac users can update through Homebrew:
“`bash
brew upgrade git
“`
Likely Causes
Cause #1: GitHub Password Authentication Deprecation
Since August 2021, GitHub requires token-based authentication for all Git operations. Your old saved password simply won’t work anymore. Check if you’re affected by looking at your Git error message – if it mentions “Support for password authentication was removed,” this is your issue. The fix is creating a Personal Access Token as described in Step 1.
Cause #2: Expired or Revoked Credentials
Personal Access Tokens can expire or be revoked. GitHub tokens are ideal for temporary access but not recommended when you need long-term authentication. Check your tokens at GitHub.com under Settings > Developer settings > Personal access tokens. Look for expired dates or revoked status. Generate a fresh token if needed.
Cause #3: Repository Permission Changes
Sometimes the repository owner changes access permissions. You might have lost push access without realizing it. Visit the repository on GitHub.com and check if you can see the “Settings” tab. If not, you likely have read-only access. Contact the repository owner or check if you’re still listed as a collaborator under Settings > Manage access.
When to Call an Expert Help
Consider getting professional help if you’ve tried all steps and still can’t push after 30 minutes. This is especially true if you’re working on a company repository or dealing with enterprise GitHub accounts. Your IT department might have specific authentication requirements or VPN settings affecting your connection.
Also seek help if you see errors mentioning SSL certificates, proxy configurations, or if your organization uses GitHub Enterprise Server. These scenarios often require network-level troubleshooting beyond basic authentication fixes.
Copy-Paste Prompt for AI Help
Here’s a prompt you can paste into ChatGPT or Perplexity when you need more specific guidance:
“`
I’m getting “authentication failed” when pushing to GitHub in 2025. Here’s my setup:
- Operating System: [Windows/Mac/Linux]
- Git version: [paste output of git –version]
- Error message: [paste exact error]
- I’ve already tried: [list what you’ve done]
- Using HTTPS or SSH: [specify which]
- 2FA enabled: [yes/no]
Please help me troubleshoot this GitHub authentication issue with specific commands for my setup.
“`
Remember, GitHub authentication errors are fixable. Most users resolve this by creating a new Personal Access Token or switching to SSH keys. Take it step by step, and you’ll be pushing code again within minutes.