Support for password authentication was removed on August 13, 2021. Please use a personal access token instead

avatar
Borislav Hadzhiev

Last updated: Apr 5, 2024
8 min

banner

# Support for password authentication was removed on August 13, 2021. Please use a personal access token instead

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.

support for password authentication was removed on august 13

shell
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:

  1. Visit https://github.com and in the upper-right corner, click on your profile picture and then click Settings.

click profile photo click settings

  1. In the left sidebar, click on < > Developer settings.

click developer settings

  1. In the left sidebar, click on Personal access tokens and then Tokens (classic).

  2. From the Generate new token dropdown menu select Generate new token (classic).

generate new token classic

  1. Give your token a descriptive name.

give your token a name

  1. Select when the token should expire from the dropdown menu. I'll use the default expiration of 30 days.

  2. I'll check all checkboxes in the Select scopes section, but you can only select the scopes you require for fine-grained control.

select scopes check all checkboxes

  1. Click on the Generate token button.

click generate token

  1. IMPORTANT - Make sure to copy your Personal Access Token now. You won't be able to see it again.

copy personal access token

  1. Treat your access token like a password. You can enter your token instead of your password when performing Git operations over HTTPS.

  2. Store your Personal Access token in a local file or in a secure remote password manager.

If you need to clone a private GitHub repository or push to a repository, you can use your Personal Access Token when you get prompted for a password.
  1. For example, if I open a private repository and click on Code and then HTTPS.

click code https

  1. I can copy the HTTPS git URL and use it to clone the private repository with my token.
shell
git clone https://github.com/YOUR_USERNAME/REPO.git Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN

clone private repository using personal access token

  1. 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.

  2. 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.

shell
git clone https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git

clone github repo using token linux

The token is specified in the repository URL.

shell
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.

shell
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

git remote set url origin

If you get prompted for a password when pushing to a repository, enter your Personal Access token in the place of the password.

shell
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.

If you update your Git credentials to use your token (instead of your old password) globally, it works for all Git operations.

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.

  1. Update your Git credentials on Windows
  2. Update your Git credentials on macOS
  3. Update your Git credentials on Linux
  4. Update your Git credentials using SourceTree
  5. Update your Git credentials using Github CLI

# Update your Git credentials on Windows

To update your Git credentials and replace your old password with the Personal access token on Windows:

  1. Click on the Search bar, type Credential Manager and start the application.

search credential manager

  1. Click on Windows Credentials.

click on windows credentials

  1. Find the 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.

find git github com entry

  • In the Password field, replace your old password with your Personal Access Token and click on the Save button to confirm.

replace old password with token windows

  • Note: if you have a git:https://YOUR_USERNAME@github.com entry, edit it as well. Specify your username and paste the Personal access token as the password.

edit both github entries windows

  1. If you don't see the git:https://github.com entry, click on Add a generic credential.

click add a generic credential

  • In the Internet or network address field, enter git:https://github.com.
  • In the User name field, enter your GitHub username.
  • In the Password field, enter your Personal Access Token.
  • Click OK to confirm.
  1. If you still get an error when issuing Git commands, click on Add a generic credential.
  • In the Internet or network address field, enter git:https://YOUR_USERNAME@github.com.
  • In the User name field, enter your GitHub username.
  • In the Password field, enter your Personal Access Token.
  • Click OK to confirm.

edit both github entries windows

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.

shell
git clone https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git

clone github repo using token linux

The token is specified in the repository URL.

shell
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.

shell
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

git remote set url origin

If you get prompted for a password when pushing to a repository, enter your Personal Access token in the place of the password.

shell
git push Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN

Note that Personal access tokens can only be used for HTTPS Git operations.

# Update your Git credentials on macOS

To update your Git credentials and replace your old password with the Personal access token on macOS:

  1. Click on the magnifying glass in the top right corner and type Keychain Access in the search field and start the application.

macos search keychain access

  1. In the search field, type 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.

edit github com entry macos

  1. Click on the Show password checkbox, paste your Personal Access Token and click Save Changes.

paste personal access token in password field macos

  1. If you don't see the github.com entry when you search in the Keychain Access application:
  • Clone a GitHub repository using HTTPS.
  • Authenticate using your GitHub Username and your Personal Access Token (as the Password).
shell
git clone https://github.com/YOUR_USERNAME/REPO.git Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN

clone private repository using 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.

paste personal access token in password field macos

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.

shell
git clone https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git

clone github repo using token linux

The token is specified in the repository URL.

shell
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.

shell
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

git remote set url origin

If you get prompted for a password when pushing to a repository, enter your Personal Access token in the place of the password.

shell
git push Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN

Note that Personal access tokens can only be used for HTTPS Git operations.

# Update your Git credentials on Linux

To update your Git credentials and replace your old password with the Personal access token on Linux:

  1. Open your terminal and configure the local Git client with a username and an email address. Make sure to replace the placeholders with the actual values.
shell
# ๐Ÿ‘‡๏ธ 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 config name email linux

  1. Now you can use your GitHub username and your Personal access token (in the place of a password) to authenticate with GitHub.
shell
git clone https://github.com/YOUR_USERNAME/REPO.git Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN

clone private repository using personal access token

  1. If you want to cache your HTTPS credentials, so you don't have to authenticate every time, use the following command.
shell
git config --global credential.helper cache git config --list
  1. The command tells Git to keep your credentials cached in memory for 15 minutes by default.

  2. 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.

shell
# ๐Ÿ‘‡๏ธ 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"
  1. You can delete the cache with the following commands.
shell
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.

shell
git clone https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git

clone github repo using token linux

The token is specified in the repository URL.

shell
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.

shell
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

git remote set url origin

If you get prompted for a password when pushing to a repository, enter your Personal Access token in the place of the password.

shell
git push Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN

Note that Personal access tokens can only be used for HTTPS Git operations.

# Update your Git credentials using SourceTree

To update your Git credentials and replace your old password with the Personal access token using SourceTree:

  1. Double-click on a repository in SourceTree.

  2. In the top right, click on the little arrow that points downwards and click Settings.

source tree click settings

  1. Click on the Remotes tab and then select your origin and click Edit.

in remotes tab click edit

  1. Your URL / PATH will look something like https://github.com/YOUR_GITHUB_USERNAME/YOUR_GITHUB_REPOSITORY.

  2. Edit the URL / PATH field and set it to the following.

shell
https://<YOUR_TOKEN>@github.com/<YOUR_USERNAME>/<YOUR_REPO>.git

edit url path sourcetree

Make sure to replace the placeholders with the actual values.

  1. Click on the OK button to confirm the changes.

Note that Personal access tokens can only be used for HTTPS Git operations.

# Update your Git credentials using Github CLI

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.

shell
gh auth login
QuestionAnswer
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:-

github cli set up authentication token login

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.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev