The error message "support for password authentication was removed" has become a familiar roadblock for developers pushing code to remote repositories. If you have encountered this while trying to git push or git pull over HTTPS, you are not alone. Think about it: this change, implemented by major Git hosting providers like GitHub, GitLab, and Bitbucket, marks a significant shift in how developers secure their workflows. Understanding why this happened and how to fix it is essential for maintaining a smooth, secure development pipeline.
Easier said than done, but still worth knowing.
Why Was Password Authentication Removed?
The decision to remove support for password authentication was not arbitrary; it was a necessary evolution in security posture. For years, developers used their account passwords directly in the terminal or stored them in credential managers to authenticate Git operations over HTTPS. While convenient, this approach carried substantial risks.
Credential Leakage and Phishing Passwords are frequently reused across multiple platforms. If a developer’s credentials were exposed in a data breach on an unrelated site, attackers could attempt those same credentials on Git hosting platforms. Adding to this, phishing attacks targeting developers often mimic login pages to harvest passwords. Once an attacker has a valid password, they have full write access to private repositories, potentially injecting malicious code or stealing intellectual property Surprisingly effective..
Lack of Granular Control A primary account password grants total access. It cannot be scoped to specific repositories, nor can it be limited to read-only access. If a Continuous Integration (CI) server or a third-party tool required access, it needed the master keys to the kingdom. Revoking access meant changing the master password, breaking every other integration simultaneously Not complicated — just consistent..
The Rise of Token-Based Authentication The industry standard has shifted toward Personal Access Tokens (PATs) and SSH keys. These methods offer distinct advantages:
- Scoped Permissions: Tokens can be restricted to specific actions (e.g.,
repoaccess only, noadmin:orgrights). - Revokability: A compromised token can be deleted instantly without affecting the primary account login or other tokens.
- Auditability: Token usage is logged separately, providing clearer audit trails.
- Expiration: Tokens can be set to expire automatically, enforcing hygiene.
GitHub led this charge on August 13, 2021, officially deprecating account passwords for Git authentication. On top of that, gitLab and Bitbucket followed suit with similar timelines and policies. The error message you see is the enforcement of this policy.
The Immediate Fix: Using a Personal Access Token (PAT)
For most developers using HTTPS, the quickest resolution is generating a Personal Access Token. Think of a PAT as a specialized, revocable password designed specifically for API and Git authentication.
Step-by-Step Guide to Creating a PAT (GitHub Example)
While the UI varies slightly between providers, the concept remains identical Not complicated — just consistent..
- handle to Settings: Log in to your provider (e.g., GitHub) and go to Settings > Developer settings (usually at the bottom of the left sidebar).
- Select Personal Access Tokens: Choose Fine-grained tokens (recommended for modern security) or Tokens (classic).
- Fine-grained tokens allow you to select specific repositories and granular permissions (Read/Write access to Contents, Metadata, Pull Requests, etc.). This is the most secure option.
- Classic tokens use broader scopes (like
repo,workflow,admin:org). These are easier to configure but follow the principle of least privilege less strictly.
- Configure the Token:
- Name: Give it a descriptive name (e.g.,
laptop-cli-accessorci-cd-pipeline). - Expiration: Set an expiration date. Never select "No expiration" for daily driver tokens. 90 days is a standard balance; 30 days is better for high-security environments.
- Repository Access: Select "Only select repositories" and pick the specific repos you need to push/pull.
- Permissions: Grant only what is needed. For standard push/pull, you typically need Contents: Read and Write and Metadata: Read.
- Name: Give it a descriptive name (e.g.,
- Generate and Copy: Click Generate token. Copy the token immediately. You will not be able to see it again. Treat it exactly like a password.
Updating Your Local Git Configuration
Once you have the token, you need to tell Git to use it instead of your password.
Option A: Credential Helper (Recommended) Most operating systems have a secure credential store (Keychain on macOS, Credential Manager on Windows, libsecret on Linux). Git can cache the token there so you only enter it once Less friction, more output..
Run this command in your terminal:
git config --global credential.helper store
Or for macOS:
git config --global credential.helper osxkeychain
Or for Windows:
git config --global credential.
The next time you run `git push`, Git will prompt for your username and password. Enter your **username** (or email) and paste the **PAT** as the password. The credential helper will save it securely for future operations.
**Option B: Embedding in Remote URL (Not Recommended for Shared Machines)**
You can update the remote URL to include the token:
```bash
git remote set-url origin https://@github.com/username/repo.git
Warning: This writes the token in plain text to your .git/config file. Avoid this on shared systems or if you commit your .git folder accidentally Easy to understand, harder to ignore..
The solid Alternative: SSH Keys
While PATs fix the HTTPS workflow, many engineers prefer SSH (Secure Shell) keys. SSH uses asymmetric cryptography (a public/private key pair), eliminating the need to transmit secrets over the network entirely Simple, but easy to overlook..
Why Choose SSH?
- No Tokens to Rotate: Once set up, keys don't expire (unless you enforce rotation policy).
- Agent Forwarding:
ssh-agentholds your decrypted key in memory, allowing seamless authentication without typing passphrases repeatedly. - Standard for Automation: CI/CD pipelines and servers almost universally prefer SSH keys for deployment keys.
Setting Up SSH Authentication
-
Generate a Key Pair:
ssh-keygen -t ed25519 -C "your_email@example.com"Use
ed25519for modern, fast, secure keys. RSA 4096 is the legacy fallback. Press Enter to accept the default file location (~/.ssh/id_ed25519). Enter a strong passphrase. This encrypts the private key on disk. If your laptop is stolen, the key is useless without the passphrase. -
Start the SSH Agent and Add Key:
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519On macOS, add
--apple-use-keychainto store the passphrase in Keychain. On Windows, ensure the OpenSSH Authentication Agent service is running. -
Add Public Key to Provider: Copy the public key content:
cat ~/.ssh/id_ed25519.pub # Or on macOS: pbcopy < ~/.ssh/id_ed25519.pubPaste this into Settings > SSH and GPG Keys > New SSH Key on GitHub/GitLab/Bitbucket.
-
Update Remote URL to SSH:
git remote set-url origin git@github.com:username/repo.gitNote the format:
git@host:user/repo.gitvshttps://host/user/repo.git. -
Test Connection:
ssh -T git@github.com