GitHub Password Authentication Removal: Using Personal Access Tokens and SSH
IMPORTANT UPDATE
As of August 13, 2021, GitHub removed password authentication for Git operations. You must now use personal access tokens or SSH keys to interact with your repositories.
Problem Statement
When attempting to perform Git operations like git push
, git pull
, or git clone
, you may encounter the error:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for...
This occurs because GitHub no longer accepts account passwords for Git operations, requiring alternative authentication methods.
Recommended Solutions
Option 1: Use Personal Access Tokens (PAT)
Personal Access Tokens provide a secure alternative to password authentication for HTTPS Git operations.
Generating a PAT
- Go to GitHub Settings → Developer Settings → Personal Access Tokens → Tokens (classic)
- Click Generate new token (classic)
- Provide a descriptive note for the token
- Set an appropriate expiration date
- Select necessary scopes (typically
repo
for full repository access) - Click Generate token
- Copy the token immediately - you won't be able to see it again
Configuring Your System with PAT
# Clone with token
git clone https://<TOKEN>@github.com/<USERNAME>/<REPO>.git
# Or update existing remote URL
git remote set-url origin https://<TOKEN>@github.com/<USERNAME>/<REPO>.git
# Same commands work on Windows
git remote set-url origin https://<TOKEN>@github.com/<USERNAME>/<REPO>.git
Storing PAT in System Credential Manager
# Use Keychain Access to store token
# Search for "Keychain Access" → Find "github.com" → Update password with token
# Use Credential Manager
# Control Panel → User Accounts → Credential Manager → Windows Credentials
# Find "git:https://github.com" → Edit → Replace password with token
# Cache credentials temporarily
git config --global credential.helper cache
# Or store permanently (use with caution)
git config --global credential.helper store
Option 2: Use SSH Authentication (Recommended)
SSH keys provide a more secure and convenient authentication method that doesn't require token management.
Setting Up SSH Keys
Generate SSH key pair (if you don't have one):
bashssh-keygen -t ed25519 -C "your_email@example.com"
Add SSH key to SSH agent:
basheval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
Add public key to GitHub:
- Copy contents of
~/.ssh/id_ed25519.pub
- Go to GitHub SSH Keys settings
- Click New SSH key, paste your key, and save
- Copy contents of
Update remote URL to use SSH:
bashgit remote set-url origin git@github.com:USERNAME/REPOSITORY.git
Test SSH connection:
bashssh -T git@github.com
Option 3: Use GitHub CLI
The GitHub CLI tool simplifies authentication and Git operations:
# Install GitHub CLI (macOS with Homebrew)
brew install gh
# Authenticate with GitHub
gh auth login
# Setup Git to use GitHub CLI authentication
gh auth setup-git
IDE-Specific Solutions
JetBrains IDEs (IntelliJ, WebStorm, PyCharm, etc.)
- Open Settings/Preferences → Version Control → GitHub
- Click Add Account
- Select Log In with Token
- Paste your personal access token
- Click Add Account
Android Studio
- Generate a personal access token on GitHub
- Remove existing GitHub account from Android Studio
- Add account again using the new token
- If issues persist, update the remote URL in terminal:bash
git remote set-url origin https://<TOKEN>@github.com/<USERNAME>/<REPO>.git
Sourcetree
- Go to Tools → Options → Authentication
- Select your GitHub account
- Click Refresh OAuth Token
- Or update repository URL to include token:bash
https://<TOKEN>@github.com/USERNAME/REPOSITORY.git
Advanced Configuration
Centralized PAT Management
For users with multiple repositories, manage tokens centrally using Git's include functionality:
In each repository's .git/config
:
[remote "origin"]
url = https://github.com/<user>/<repo>.git
[include]
path = ~/.github-token
In ~/.github-token
:
[url "https://<TOKEN>@github.com/<user>/"]
pushInsteadOf = https://github.com/<user>/
Force SSH for All Operations
To always use SSH instead of HTTPS:
git config --global url."git@github.com:".insteadOf "https://github.com/"
Troubleshooting Common Issues
"No such remote 'origin'"
If you encounter this error when trying to set URL:
# First add the remote origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git
# Then update the URL with token
git remote set-url origin https://<TOKEN>@github.com/USERNAME/REPOSITORY.git
Token Still Not Working
- Ensure token has appropriate permissions (repo scope)
- Check token expiration date
- Verify there are no typos in the token
- Clear cached credentials:bash
git config --global --unset credential.helper git credential-cache exit
Organization Repository Access
For organization repositories, ensure:
- Your account has access to the organization
- The token has appropriate organization permissions
- You're signed in to the organization with your token
Best Practices
- Use SSH when possible - More secure and doesn't require token management
- Set appropriate token expiration - Balance security and convenience
- Use token with least privileges - Only grant necessary scopes
- Store tokens securely - Use system credential managers rather than hardcoding
- Rotate tokens regularly - Especially if compromised or team members leave
Conclusion
The transition away from password authentication to PATs or SSH keys enhances security for GitHub operations. While initially requiring setup, these methods provide more controlled and secure access to your repositories. For most users, SSH keys offer the best combination of security and convenience, while PATs provide flexibility for automated systems and CI/CD pipelines.
QUICK FIX
For immediate resolution, update your remote URL:
git remote set-url origin https://<TOKEN>@github.com/USERNAME/REPOSITORY.git
Or switch to SSH:
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
For additional help, refer to GitHub's official documentation on authentication methods.