Last updated: Apr 5, 2024
Reading timeยท8 min
The error "Support for password authentication was removed on August 13, 2021" occurs because GitHub has removed support for password authentication.
To solve the error, create a personal access token and use it in place of a password when authenticating with GitHub.
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. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information. fatal: Authentication failed for 'https://github.com/bobbyhadz/example.git/' fatal: unable to access. The requested URL returned error: 403
The first thing you should do is create a Personal Access Token on GitHub.
To create a Personal Access Token:
In the left sidebar, click on Personal access tokens and then Tokens (classic).
From the Generate new token dropdown menu select Generate new token (classic).
Select when the token should expire from the dropdown menu. I'll use the default expiration of 30 days.
I'll check all checkboxes in the Select scopes section, but you can only select the scopes you require for fine-grained control.
IMPORTANT -
Make sure to copy your Personal Access Token now. You won't
be able to see it again.Treat your access token like a password. You can enter your token instead of your password when performing Git operations over HTTPS.
Store your Personal Access token in a local file or in a secure remote password manager.
git clone https://github.com/YOUR_USERNAME/REPO.git Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN
I entered my GitHub username and when prompted for a Password, I entered the Personal Access Token in the place of a password to clone the private repository.
Note that Personal access tokens can only be used for HTTPS Git operations.
Now you can also use the following syntax to clone a GitHub repository over HTTPS.
git clone https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
The token is specified in the repository URL.
https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
You can also use the URL in the specified form when issuing the
git remote set-url origin
command.
git remote add origin https://github.com/<YOUR_USERNAME>/<YOUR_REPO>.git git remote set-url origin https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git git remote --v
If you get prompted for a password when pushing to a repository, enter your Personal Access token in the place of the password.
git push Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN
However, if you use this approach you will have to repeat the steps for each local repository.
You should also update your Git credentials if you don't get prompted for a
password when you issue git
commands.
The steps for updating your Git credentials are different depending on your Operating System or the Git graphic user interface you use.
Click on the link that's relevant to you to scroll down to the related subheading.
To update your Git credentials and replace your old password with the Personal access token on Windows:
git:https://github.com
entry, click on it and select Edit.
NOTE: if you don't see the git:https://github.com
entry, read the next list
item.git:https://YOUR_USERNAME@github.com
entry, edit it as
well. Specify your username and paste the Personal access token as the
password.git:https://github.com
entry, click on Add a generic
credential.git:https://github.com
.git:https://YOUR_USERNAME@github.com
.After you have replaced your old password with your Personal Access Token, you won't get the error anymore and you won't get prompted for credentials when using HTTPS git commands.
You can also use the following syntax to clone a GitHub repository over HTTPS.
git clone https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
The token is specified in the repository URL.
https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
You can also use the URL in the specified form when issuing the
git remote set-url origin
command.
git remote add origin https://github.com/<YOUR_USERNAME>/<YOUR_REPO>.git git remote set-url origin https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git git remote --v
If you get prompted for a password when pushing to a repository, enter your Personal Access token in the place of the password.
git push Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN
Note that Personal access tokens can only be used for HTTPS Git operations.
To update your Git credentials and replace your old password with the Personal access token on macOS:
github.com
, then find the corresponding
Internet password entry and double-click on it. If you don't see the
github.com
entry, check out list item 4.github.com
entry when you search in the Keychain
Access application:git clone https://github.com/YOUR_USERNAME/REPO.git Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN
Then search for github.com
in the Keychain Access application again and
the entry will be there.
Double-click on the entry to edit it. Click on the Show password checkbox, paste your Personal Access Token and click Save Changes.
After you have replaced your old password with your Personal Access Token, you won't get the error anymore and you won't get prompted for credentials when using HTTPS git commands.
You can also use the following syntax to clone a GitHub repository over HTTPS.
git clone https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
The token is specified in the repository URL.
https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
You can also use the URL in the specified form when issuing the
git remote set-url origin
command.
git remote add origin https://github.com/<YOUR_USERNAME>/<YOUR_REPO>.git git remote set-url origin https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git git remote --v
If you get prompted for a password when pushing to a repository, enter your Personal Access token in the place of the password.
git push Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN
Note that Personal access tokens can only be used for HTTPS Git operations.
To update your Git credentials and replace your old password with the Personal access token on Linux:
# ๐๏ธ delete the old Cache git config --global --unset credential.helper git config --local --unset credential.helper # ๐๏ธ configure username and email address git config --global user.name "YOUR_GITHUB_USERNAME" git config --global user.email "YOUR_GITHUB_EMAIL" git config --list
git clone https://github.com/YOUR_USERNAME/REPO.git Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN
git config --global credential.helper cache git config --list
The command tells Git to keep your credentials cached in memory for 15 minutes by default.
You can cache your credentials for a longer duration by setting the timeout
parameter to the number of minutes the credentials should be cached for.
# ๐๏ธ Cache credentials for 1 hour git config --global credential.helper "cache --timeout=3600" # ๐๏ธ Cache credentials for 1-day git config --global credential.helper "cache --timeout=86400"
git config --global --unset credential.helper git config --local --unset credential.helper git config --system --unset credential.helper
You can also use the following syntax to clone a GitHub repository over HTTPS.
git clone https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
The token is specified in the repository URL.
https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
You can also use the URL in the specified form when issuing the
git remote set-url origin
command.
git remote add origin https://github.com/<YOUR_USERNAME>/<YOUR_REPO>.git git remote set-url origin https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git git remote --v
If you get prompted for a password when pushing to a repository, enter your Personal Access token in the place of the password.
git push Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN
Note that Personal access tokens can only be used for HTTPS Git operations.
To update your Git credentials and replace your old password with the Personal access token using SourceTree:
Double-click on a repository in SourceTree.
In the top right, click on the little arrow that points downwards and click Settings.
Your URL / PATH will look something like
https://github.com/YOUR_GITHUB_USERNAME/YOUR_GITHUB_REPOSITORY
.
Edit the URL / PATH field and set it to the following.
https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git
Make sure to replace the placeholders with the actual values.
Note that Personal access tokens can only be used for HTTPS Git operations.
If you don't already have GitHub CLI installed, view the official installation instructions.
Once GitHub CLI is installed, open your terminal and run the gh auth login
command.
gh auth login
Question | Answer |
---|---|
What accounts do you want to log into? | GitHub.com |
You are already logged into github.com. Do you want to re-authenticate? | y |
What is your preferred protocol for Git operations? | HTTPS |
How would you like to authenticate GitHub CLI? | Paste an authentication token |
Paste your authentication token: | - |
Make sure to select HTTPS when you get prompted for your preferred protocol for Git operations.
Note that Personal access tokens can only be used for HTTPS Git operations.