Symptoms & Diagnosis
The “git fatal: authentication failed for” error occurs when the remote server rejects your login attempt. This usually happens during git push or git pull operations. It signifies that the credentials provided by your local Git client do not match what the server expects.
Common symptoms include a command-line prompt that repeatedly asks for a username and password, followed by a blunt “fatal” error message. In many cases, this is triggered by the deprecation of account passwords in favor of Personal Access Tokens (PATs) on platforms like GitHub or GitLab.
To diagnose the issue, check if you have recently changed your password or if your access token has expired. You can test your connection using the following command to see where the handshake fails:
ssh -vT [email protected]

Troubleshooting Guide
The most effective way to resolve this is by refreshing your stored credentials. Most modern systems use a credential helper to store your login details. If these details are stale, Git will continue to fail without prompting for new ones.
First, try clearing your local credentials so Git is forced to ask for them again. Use the following command based on your operating system:
# For Windows (Credential Manager)
git config --global --unset credential.helper
# For macOS (Keychain)
git credential-osxkeychain erase
If you are using GitHub, remember that you cannot use your standard account password for Git operations. You must generate a Personal Access Token (PAT). Refer to the table below for common credential types:
| Credential Type | Usage Scenario | Security Level |
|---|---|---|
| Personal Access Token (PAT) | HTTPS authentication for GitHub/GitLab | High (Scoped access) |
| SSH Key | Passwordless authentication via terminal | Highest (Encrypted) |
| OAuth App | Third-party integrations | Medium |
Updating the Git Credential Manager
If you are on Windows, the Git Credential Manager (GCM) usually handles the login popup. If it fails to appear, you might need to update your Git installation or manually reset the GCM configuration:
git config --global credential.helper manager
Once updated, the next time you push code, a browser window will open allowing you to sign in via OAuth, which bypasses the need for manual token entry.
Prevention
To prevent “authentication failed” errors in the future, transition from HTTPS to SSH. SSH keys are more secure and do not expire like passwords or certain tokens. Once configured, your machine is “trusted” by the server indefinitely.
Generate a new SSH key and add it to your Git provider settings to avoid login prompts entirely:
ssh-keygen -t ed25519 -C "[email protected]"
Always set an expiration reminder for your Personal Access Tokens. Most platforms allow you to set a 30, 60, or 90-day limit. When the token expires, you will see the fatal authentication error again, reminding you to rotate your secrets.
Finally, ensure your global Git configuration is correct. Sometimes, a typo in your username or email in the local config can lead to mismatch errors during the authentication handshake.