Every developer has been there. You’ve been coding away, everything’s working perfectly, and then you hit git push only to be greeted by this lovely message:

remote: Support for password authentication was removed on August 13, 2021.
fatal: Authentication failed for 'https://github.com/username/repository.git'

“Wait, what? I definitely entered my password correctly!” Don’t worry – you’re not going crazy, and you’re definitely not alone. This happens because GitHub completely ditched password authentication back in August 2021, and now you need to use either Personal Access Tokens or SSH keys.

In this guide, I’ll walk you through why this happens and show you exactly how to fix it. No more authentication headaches interrupting your development flow!

 

1. What’s Actually Going On Here?

GitHub’s Security Policy Changes

GitHub made a big security upgrade on August 13, 2021, completely removing support for password authentication in HTTPS Git operations. Now you have to use either Personal Access Tokens (PATs) or SSH keys – both much more secure options.

The Main Culprits

1. Still Using Password Authentication

  • Your old username/password combo just doesn’t work anymore
  • If you’re using HTTPS URLs, you’ll need a PAT

2. Expired Personal Access Token

  • Your existing token might have expired or been revoked
  • Token permissions (scopes) might not be right for what you’re trying to do

3. SSH Key Issues

  • SSH key isn’t registered with GitHub or set up incorrectly
  • SSH agent isn’t running or your key isn’t loaded

4. Stored Credential Problems

  • Old authentication info stored on your system causing conflicts
  • Outdated info in Windows Credential Manager, macOS Keychain, etc.

5. Common Error Messages and What They Mean

Error Message What’s Wrong
“Support for password authentication was removed” GitHub doesn’t accept passwords anymore
“Permission denied (publickey)” SSH key isn’t registered or loaded
“fatal: Could not read from remote repository” No access to the repo
“Authentication failed for HTTPS” Bad or expired PAT

 

2. Solutions

Solution 1: Personal Access Token (PAT) Setup

Personal Access Tokens are like secure passwords that GitHub generates for you. They’re way safer than regular passwords and give you fine-grained control over permissions.

Step 1: Create Your PAT

  1. Head to GitHub and click your profile picture (top right)
  2. Go to “Settings”
  3. Click “Developer settings” in the left sidebar
  4. Choose “Personal access tokens” → “Tokens (classic)”
  5. Hit “Generate new token” or “Generate new token (classic)”
  6. You might need to enter your GitHub password again

Step 2: Configure Your Token

Field What to Put Example
Note What this token is for “Local Development Access”
Expiration How long it should last 90 days or 1 year
Scopes What permissions it needs repo (for full repository access)

⚠️ Important: Once you leave this page, you’ll never see the token again. Copy it and save it somewhere safe!

Step 3: Using Your PAT

Option 1: Include it in the URL

git remote set-url origin https://your_token@github.com/username/repository.git
# or
git push https://your_token@github.com/username/repository.git

Option 2: Enter it when prompted

git push origin main
Username: your_github_username
Password: your_personal_access_token  # Use your token here, not your password!

Option 3: Save it with credential helper

# Store it globally so you don't have to keep entering it
git config --global credential.helper store

 

Solution 2: SSH Key Setup (Recommended)

SSH keys are the gold standard. Set them up once, and Git will authenticate automatically forever. No more typing tokens!

Step 1: Check for Existing SSH Keys

See if you already have SSH keys:

ls -al ~/.ssh

If you see files like these, you already have SSH keys:

  • id_rsa (private key)
  • id_rsa.pub (public key)
  • id_ed25519 (private key, newer algorithm)
  • id_ed25519.pub (public key, newer algorithm)

Step 2: Generate New SSH Keys

If you don’t have keys or want new ones:

# Use ED25519 algorithm (recommended)
ssh-keygen -t ed25519 -C "your_email@example.com"

# Use RSA if you need compatibility with older systems
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

During generation:

  1. File location: Hit Enter for default, or specify a custom path
  2. Passphrase: Recommended for security (but optional)

Step 3: Add Key to SSH Agent

On macOS:

# Start SSH agent
eval "$(ssh-agent -s)"

# Add to keychain (saves your passphrase)
ssh-add --apple-use-keychain ~/.ssh/id_ed25519

On Windows:

# Start SSH agent
eval "$(ssh-agent -s)"

# Add your key
ssh-add ~/.ssh/id_ed25519

Step 4: Add Public Key to GitHub

First, copy your public key:

# macOS
pbcopy < ~/.ssh/id_ed25519.pub

# Windows (Git Bash)
clip < ~/.ssh/id_ed25519.pub

# Linux
cat ~/.ssh/id_ed25519.pub

Then add it to GitHub:

  1. GitHub → Settings → SSH and GPG keys
  2. Click “New SSH key”
  3. Title: Something like “My Laptop”
  4. Key: Paste your copied public key
  5. Click “Add SSH key”

Step 5: Test Your SSH Connection

Make sure everything’s working:

ssh -T git@github.com

If it worked, you’ll see:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Step 6: Switch from HTTPS to SSH

Change your repository URL:

# Check current URL
git remote -v

# Switch to SSH
git remote set-url origin git@github.com:username/repository.git

 

Solution 3: Fix Credential Manager Issues

Sometimes your system stores old authentication info that causes problems.

Windows Credential Manager

GUI Method:

  1. Search for “Credential Manager” in Windows
  2. Click “Windows Credentials”
  3. Find GitHub entries
  4. Edit or remove them

Command Line Method:

# Check current credential settings
git config --list | grep credential

# Reset credential helper
git config --global --unset credential.helper
git config --global credential.helper manager-core

macOS Keychain

GUI Method:

  1. Open Spotlight and search “Keychain Access”
  2. Search for “github.com”
  3. Edit or delete the entries

Command Line Method:

# Remove GitHub credentials from keychain
git credential-osxkeychain erase
# Then enter:
# protocol=https
# host=github.com
# [Press Enter twice]

Linux

rm ~/.git-credentials
git config --global --unset credential.helper

 

Solution 4: Git Credential Manager (GCM)

Git Credential Manager handles authentication automatically, including 2FA. It’s like having a smart assistant for your Git authentication.

Installation:

macOS (Homebrew):

brew install --cask git-credential-manager-core

Windows:

Linux:

# Debian/Ubuntu
curl -LO https://github.com/GitCredentialManager/git-credential-manager/releases/latest/download/gcm-linux_amd64.2.0.877.deb
sudo dpkg -i gcm-linux_amd64.2.0.877.deb

Configuration:

git config --global credential.credentialStore secretservice

 

Solution 5: Special Setup for 2FA Users

If you have two-factor authentication enabled on GitHub, there are some extra considerations.

Using Personal Access Tokens

With 2FA enabled, you absolutely must use a PAT instead of your regular password:

# Username: Your GitHub username
# Password: Your Personal Access Token (NOT your regular password!)

GitHub CLI (Easiest for 2FA)

GitHub CLI handles 2FA authentication seamlessly:

Install:

# macOS
brew install gh

# Windows (Chocolatey)
choco install gh

# Linux (Debian/Ubuntu)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh

Authenticate:

gh auth login
# Choose HTTPS and follow the browser authentication flow

 

Solution 6: Quick Fixes for Specific Errors

“Support for password authentication was removed”

Fix: Use a Personal Access Token or set up SSH keys

“Permission denied (publickey)”

Fix:

# Check if your key is loaded
ssh-add -l

# If not, add it
ssh-add ~/.ssh/id_ed25519

# Make sure your public key is registered on GitHub

“fatal: Could not read from remote repository”

Fix:

# Check your repository URL
git remote -v

# Test SSH connection
ssh -T git@github.com

“Authentication failed for HTTPS”

Fix:

  1. Check if your token is still valid on GitHub
  2. Generate a new token
  3. Clear stored credentials and try again

 

 

3. Quick Troubleshooting Checklist

When things go wrong, try these steps in order:

✅ Step 1: Basic Checks

  • [ ] Make sure your GitHub account is working
  • [ ] Verify you have push access to the repository
  • [ ] Check your internet connection

✅ Step 2: Check Authentication Method

# See what URL you're using
git remote -v

# HTTPS = need PAT or switch to SSH
# SSH = check SSH key setup

✅ Step 3: Clear Stored Credentials

# Windows
git config --global --unset credential.helper
rundll32.exe keymgr.dll,KRShowKeyMgr

# macOS
git config --global --unset credential.helper
git credential-osxkeychain erase

# Linux
git config --global --unset credential.helper
rm ~/.git-credentials

✅ Step 4: Set Up Fresh Authentication

For PAT:

git config --global credential.helper store
git push origin main
# Enter username and PAT when prompted

For SSH:

# Test SSH connection
ssh -T git@github.com

# Switch URL to SSH
git remote set-url origin git@github.com:username/repository.git

 

 

Authentication errors can be frustrating, but they’re totally fixable once you understand what’s happening. GitHub’s security changes are actually a good thing – they make your code more secure.

Both Personal Access Tokens and SSH keys have their place. SSH keys are great for convenience (set once, forget forever), while PATs give you granular control over permissions. Pick whatever works best for your workflow.

With these solutions in your toolkit, authentication errors won’t derail your development flow anymore. Happy coding!

 

댓글 남기기