Daemes
Daemes

Reputation: 16857

Message "Support for password authentication was removed."

I got this error on my console when I tried to use git pull:

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

It's very weird, because I just followed the documentation and created a token two weeks ago on GitHub. The token expires on Tue, Oct 26, 2021. Why has this been removed today?

Upvotes: 1791

Views: 2377212

Answers (30)

Lane
Lane

Reputation: 5035

Maybe it not the answer, yet I met a similar issue. To solve it, I just changed the

git remote add origin https://github.com/blog5-com/blog5.git

into

git remote add origin git@github.com:blog5-com/blog5.git

.

Upvotes: 0

Ashwini Singh
Ashwini Singh

Reputation: 41

  1. Go to your GitHub Developer Settings.
  2. Click Generate new token (classic).
  3. Select the necessary scopes (e.g., repo for full repository control).
  4. Click Generate token and copy the token.

Upvotes: 2

Suraj Verma
Suraj Verma

Reputation: 453

Generate an access token in GitHub from SettingsDeveloper settingsPersonal Access TokensClassic tokensGenerate New Token

If you have cloned your repository in the past and made it as origin, then you can change the authentication so,

git remote set-url origin https://<token>@github.com/<username>/<repo>.git

Upvotes: -2

Nodo
Nodo

Reputation: 105

If you use a PAT, but still got this error, open the configuration file and clear it.

git config --global --edit

Upvotes: -1

Roho
Roho

Reputation: 64

The most annoying thing with the PAT is that they expire quite rapidly. You get an expiry notice email and it has to be renewed. If you have several repositories cloned locally, you have to update the PAT in the .git/config in all of them and you're bound to forget some of them, which then don't work anymore (for pushing).

Typically, you would have in <repo>/.git/config of every cloned repository:

[remote "origin"]
    url = https://github.com/<user>/<repo>.git
    pushurl = https://<PAT>@github.com/<user>/<repo>.git

If you instead use the [include] facility of git-config and the URL rewriting of git-push, then the PAT can be stored in a single file, for instance ~/github.git. You have only static data in <repo>/.git/config:

[remote "origin"]
    url = https://github.com/<user>/<repo>.git
# remove the pushurl = https://<PAT>@github.com/<user>/<repo>.git
[include]
    path = ~/github.git

and the PAT centrally in ~/github.git, which is the only file that needs editing when the PAT is renewed:

[url "https"//<PAT>@github.com/<user>/"]
    pushInsteadOf = https://github.com/<user>/

It was tested and worked very nicely.

Probably, you could also just put the [url] pushInsteadOf in your per-user git configuration file ~/.gitconfig and you don't need to use [include] in the per-repository configuration.

On the other hand, the 'ssh://' method still works too and has none of the problems of PAT. Just put your SSH public key in your GitHub account.

Upvotes: 0

Raw Hasan
Raw Hasan

Reputation: 1396

Android Studio Arctic Fox Solution (Windows 10)

I was authenticated in Android Studio 4.2 (Arctic Fox) (latest version) using a personal access token, but still, I was getting this error on August 14, 2021:

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

I generated a new access token on github.com, removed my GitHub account from Android Studio, and added the account again with the new access token. But still, it was showing the same error.

Reading other solutions on Stack Overflow, I downloaded the GitHub CLI, and added my GitHub account in the Windows command prompt with the access token successfully, and tried to push the repository from Android Studio again, which again failed.

Then following this article, I did the following at the command line:

cd <project-directory>
git remote set-url origin https://<TOKEN>@github.com/<user_name>/<repo_name>.git

I pushed again from Android Studio, and it finally worked!

Upvotes: 4

STA
STA

Reputation: 34808

From 2021-08-13, GitHub is no longer accepting account passwords when authenticating Git operations. You need to add a PAT (Personal Access Token) instead, and you can follow the below method to add a PAT on your system.

Create Personal Access Token on GitHub

From your GitHub account, go to SettingsDeveloper SettingsPersonal Access TokenTokens (classic)Generate New Token (Give your password) → Fillup the form → click Generate tokenCopy the generated Token, it will be something like ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta

Now follow the below method based on your machine:

For Windows OS

Go to Credential Manager from Control PanelWindows Credentials → find git:https://github.comEdit → On Password replace with with your GitHub Personal Access Token → You are Done

If you don’t find git:https://github.com → Click on Add a generic credential → Internet address will be git:https://github.com and you need to type in your username and password will be your GitHub Personal Access Token → Click Ok and you are done


For macOS

Click on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type Keychain access then press the Enter key to launch the app → In Keychain Access, search for github.com → Find the internet password entry for github.com → Edit or delete the entry accordingly → You are done


For a Linux-based OS

For Linux, you need to configure the local GIT client with a username and email address,

$ git config --global user.name "your_github_username"
$ git config --global user.email "your_github_email"
$ git config -l

Once GIT is configured, we can begin using it to access GitHub. Example:

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
> Cloning into `YOUR-REPOSITORY`...
Username: <type your username>
Password: <type your password or personal access token (GitHub)

Now cache the given record in your computer to remembers the token:

$ git config --global credential.helper cache

If needed, anytime you can delete the cache record by:

$ git config --global --unset credential.helper
$ git config --system --unset credential.helper

Now try to pull with -v to verify

$ git pull -v

Linux/Debian (Clone as follows):

git clone https://<tokenhere>@github.com/<user>/<repo>.git

For JetBrains IDEs

You can consult the relevant help page for your IDE of choice (IntelliJ, PhpStorm, WebStorm, GoLand, PyCharm, Rider, RustRover) for more information on logging in. Below is a short snippet of the IntelliJ help page:

Register an existing account with a token

  1. Press ⌘Сmd0/CtrlAlt0 (your actual key-binds may differ), to open settings and then select Version Control | GitHub.
  2. Click the Add button.
  3. Select Log In with Token.
  4. The token can then be inserted into the following text-field: Adding GitHub account with token
  5. Click Add Account

Upvotes: 2243

Najat
Najat

Reputation: 197

It seems like the answers to this question suffice to solve the problem. I just want to clarify one thing that I faced. If git remote set-url gives you the error message error: No such remote 'origin', you may need to add the remote origin first. So, to sum up, the steps are as follows:

  1. On GitHub, Go to Settings > Developer Settings. Then generate an access token.

  2. Run git remote add origin <repo_url>

  3. Run git remote set-url origin https://<TOKEN>@github.com/<user_name>/<repo_name>.git

  4. Run git clone https://github.com/<repo_url>.git

  5. Asks for username and password. Put your GitHub username and generated access token (as password) in respective places.

Upvotes: 2

Jaydip Meghapara
Jaydip Meghapara

Reputation: 2843

For Windows OS,

GitHub has made changes in password authentication. If you are trying to access Git by username and password then it does not allow you. So use a personal access token instead of a password to access Git everywhere.

Here are the steps to generate personal access tokens.

Click here for Token - https://github.com/settings/tokens

Step 1 - Open GitHub and log in with your credentials.

Step 2 - Click on the Setting menu.

Step 3 - From the Setting menu click on Developer Settings

Step 4 - From the Developer Settings menu, click on Personal access token

Step 5 - From the Personal access token, click on the Generate new Token button.

Step 6 - Now fill up required details like Note, Expiration, Select scopes. And then click on the Generate Token button.

Step 7 - After that, a new token has been generated. Copy that generated token and use this token to access Git with username and token.

If you are using the Windows operating system then please follow the below step.

Open Control PanelUser AccountsManage your credentialsWindows Credentials.

It will show all generic credentials. Find your GitHub URL and click on that. Now click on the edit button. And then add the personal access token generated from GitHub into the password field. And click on the Save button.

Now you can access Git.

If you are accessing Git in Android Studio, if asked for a password then add the GitHub personal access token instead of your password everywhere.

Upvotes: 212

kartik tyagi
kartik tyagi

Reputation: 7190

If you're using macOS, just simply follow these steps:

  1. Go to this link: (Profile -> settings -> developers setting -> personal access tokens). (don't go to repository setting; it's your profile setting)
  2. Generate a new token and copy-paste it somewhere safely.
  3. Now search for an app in your Mac, named Keychain Access.
  4. Search for github.com (if there are multiple GitHub logins then choose Kind: Internet password), double-click it.
  5. Click on show password, then enter your Mac's password and hit Enter.
  6. Password should be visible by now. Now, just paste the token you generated in step 2 and click Save changes.

And that's it. Enjoy!

If you're using Windows:

  1. Follow steps 1 and 2 as above.
  2. Search for an application in your Windows OS, named Credential Manager → then Windows Credentials.
  3. Search for github.com and edit the password with the token you have generated on GitHub. Now enjoy!

Developer's hack (shortcode):

git remote set-url origin https://<githubtoken>@github.com/<username>/<repositoryname>.git

While cloning:

git clone https://<username>:<githubtoken>@github.com/<username>/<repositoryname>.git

It will work on every OS (Mac, Windows, or Linux).

Cons: You have to remember or should need to do to each repository in your local. So I'll prefer everyone to use above mentioned steps.

NOTE:

For those who don't have this entry: it could be made. one way to do it is- to clone a project. then it will ask for your username and password. instead of password give it the token and then the entry would be made.

Upvotes: 625

Mithra Singam
Mithra Singam

Reputation: 2091

  1. Create a personal access token (PAT) for your account. See here to create your PAT. Your PAT should start with ghp_

  2. Open your Keychain Access app, search for GitHub, and delete your existing saved passwords

  3. Go back to your terminal and try pushing your commit. It should prompt for your user name and password. Now, try entering your PAT in place of your usual GitHub password/passphrase.

Upvotes: 1

&#193;lvaro Ag&#252;ero
&#193;lvaro Ag&#252;ero

Reputation: 4810

If you want to clone for the first time:

git clone https://<repository_owner>:<personal_access_token>@github.com/<repository_owner>/<repo>.git

Upvotes: 7

ricky
ricky

Reputation: 53

For Mac

If you do not have anything on the keychain for "GitHub", create a new keychain item and add your details. Insert the token from GitHub in place of the password.

Enter image description here

Upvotes: 3

Hana Hasanah
Hana Hasanah

Reputation: 244

I'm a Sourcetree user and fixed it by "Refresh OAuth Token" in menu ToolsOptionsAuthentication → select GitHub Account.

Enter image description here

If you have never added authentication for your GitHub account, you can refer to it on How to Connect GitHub with SourceTree (Method 1: Connect with Remote Account via OAuth).

Upvotes: -1

Al Mamun Khan
Al Mamun Khan

Reputation: 747

First you need SSH Key Based Authentication

And then

  1. Generate a personal token
  2. Set your user name: git config --global user.name "userName"
  3. Set your email address: git config --global user.email "email"
  4. git config --global credential.helper cache
  5. git push/git pull or something user name and password (personal-token)

You can follow this video: Using personal access tokens with Git and GitHub

Upvotes: 3

user3025289
user3025289

Reputation:

Simplest solution (May 2022):

  1. Create a new token at Personal access tokens
  2. Copy token (Windows: Ctrl + C, macOS: Cmd + C, or click copy icon)
  3. Try to push your local repository: git push
  4. Enter your GitHub user name
  5. Paste the token as your password

Upvotes: 70

Super Jade
Super Jade

Reputation: 6374

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

Solution

  1. Create a GitHub personal access token (PAT) and copy it.

  2. For macOS, add it to KeyChain Access under GitHub.

    Spotlight Search → type KeyChain → select KeyChain Access → search for github.com → paste your PAT

    Put your PAT in the Show password field

    For Windows, add the PAT to Windows credentials for your user.

    Search → type Credential ManagerAdd your PAT to github.com

    Enter image description here

  3. If the repository is part of an organization, you will also need to sign in to that organization with your personal access token so that the organization will recognize it. If you're already signed in, sign out first.

  4. git clone as usual :-)

Upvotes: 4

Joyanta J. Mondal
Joyanta J. Mondal

Reputation: 1047

For macOS users, just simply follow these steps:

(I have taken this part from Kartik Tyagi, but I added one of the crucial part that has been missed.)

  1. Go to this link: https://github.com/settings/tokens (Profile -> settings -> developers setting -> personal access tokens). (don't go to repository setting; it's your profile setting)
  2. Generate a new token and copy-paste it somewhere safely.
  3. Now search for an app in your Mac, named Keychain Access.
  4. Search for github.com.

If it is not present:

5.1. Click on "Create a new Keychain Item" button (the notepad-pen icon).

Keychain Item Name: https://github.com

Account Name: https://github.com (Must keep it like this. Do not add www. It will not work properly then)

Password: Paste the token you generated

If it is present:

5.2. If there are multiple GitHub logins then choose Kind: Internet password, double-click it.

  1. Click on show password, then enter your Mac's password and hit Enter.
  2. Password should be visible by now. Now, just paste the token you generated in step 2 and click Save changes.

And that should be it. Enjoy!

Upvotes: 3

Suraj
Suraj

Reputation: 894

After getting the token key, you can just skip all steps and go with this:

git clone https://your_username:your_github_token@github.com/username/private-repo.git

Upvotes: 4

Maf
Maf

Reputation: 725

You can force your machine to just use SSH instead of HTTPS:

git config --global url."git@github.com:".insteadOf "https://github.com/"

Upvotes: 17

Pau
Pau

Reputation: 16116

For those using Mac or Linux, install GH via Homebrew:

brew install gh

If you have installed and run gh auth login and still have that issue, the easiest way of solving it is just running:

gh auth setup-git

Upvotes: 1

Purva
Purva

Reputation: 411

Get an access token from GitHub:

GitHub → SettingsDeveloper settingsPersonal access tokensGenerate a new token

Copy-paste the new token into Notepad.

Open Git Bash and type the following commands:

git config --global credential.helper osxkeychain

git clone https://github.com/abc/angularProject.git

Username for 'https://github.com': Test

Password for 'https://test@github.com': (enter your token here)

Upvotes: 1

Uddhav P. Gautam
Uddhav P. Gautam

Reputation: 7636

  1. Use SSH (forget https) (E.g., don't use https url for cloning)
  2. Use Personal Access Token (PAT) (forget username/password)

(e.g., Settings > Developer Settings > Personal Access Token)

  1. Update git to latest version (e.g., 2.35.1) //I think this is important
  2. In Github, Uncheck Settings > Developer Settings > Keep my email addresses private

Conclusion: You add Personal Access token in Github. Then from any IDE (e.g., Android Studio, IntelliJ IDEA etc.) you can add remote using ssh (e.g., name: origin, URL: git@github.com:your_github_username/your_git_repo.git. That's it

If not already done,

  1. Configure git global username and email

    git config --global user.name "your_username" && git config --global user.email "your_email"

If in windows, you can add windows credentials for your user, control panel > users > manage your credential > Windows Credentials > Add a generic credential >

Internet address will be git:https://github.com and you need to type in your username and password will be your GitHub Personal Access Token => Click Ok and you are done

After this I was able to use git (fetch/push/pull etc.)

Upvotes: 2

SKARVA Bodavula
SKARVA Bodavula

Reputation: 957

I am not sure what really helped, but I know it works for me now. This is everything I've done in order:

  1. Generated the PAT and used as password - it didn't work.

  2. Cleared the github.com entry in the Windows Credential Manager - not working.

  3. Added the PAT to the repository URL like this

https://<personal-access-token>@github.com/<my-repo-url>

  • it worked, but I didn't like this solution.
  1. Restarted PC. Installed the newest Git from https://git-scm.com - and in Sourcetree - menu ToolsOptionsGitGit Version - selected "System".

  2. Removed the PAT from repository URL - it still works.

To me it looks like installing the new "Git" really helped, so step 3 may be unnecessary, but I can't be sure about that. I don't know if it would work without temporarily adding PAT to the URL. Maybe it also saved something somewhere.

Upvotes: 0

diek
diek

Reputation: 695

For Mac, go and create your token. You can only see it once. Copy it and store it securely.

Open up Terminal and run: gh auth login

*gh can be installed using Homebrew

Answer the questions. Make sure you pick HTTPS when asked.

Terminal prompt

Upvotes: 16

vagdevi k
vagdevi k

Reputation: 1685

It worked!

After getting the token key as said here:

Create Personal Access Token on GitHub From your GitHub account

go to Settings => Developer Settings => Personal Access Token => Generate New Token (Give your password) => Fillup the form => click Generate token => Copy the generated Token (it will be something like ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta)

use the following in your terminal:

git clone https://your_username:your_github_token@github.com/username/private-repo.git

Upvotes: 6

vikramvi
vikramvi

Reputation: 3635

If you're using macOS and do not find the github.com entry in the KeyChain access:

  • Try to do a Git action
  • It'll ask for the user name
  • Enter your GitHub user name
  • Generate a new key from Personal access tokens
  • In the password field, enter this newly generated token value
  • Now you can see a new entry of github.com inside KeyChain Access → login

Upvotes: 15

Aggressor
Aggressor

Reputation: 13551

To those using Sourcetree with an existing repository you must update your repository URL like so https://<your_token>@github.com/username/repo.git

This was taken from this answer.

Upvotes: 8

run_the_race
run_the_race

Reputation: 2418

I spent a few hours on this issue, with WSL 2 (Ubuntu 20.04 (Focal Fossa)). Opening a new shell worked for me. Trying the old shell, it did not work.

I am also investigating GitLab as maybe they don't have the Microsoft culture of forcing you do to things their way ("You will prefer it this way") or releasing breaking changes all the time.

Upvotes: 0

Jackson Meires
Jackson Meires

Reputation: 113

I was not able to clone the project that was always giving this error. The solution I encouraged was, after having generated the token as the post was spoken in the post, I did as described below.

Using a personal access token for the cloning of a new project.

For cloning, also you just need to modify the URL as you have done in step 2.

The older way to clone a repository:

git clone repository_URL folder_name

git clone https://github.com/<user>/<repository> my_project

The new way of cloning with a personal access token:

git clone https://<token>@github.com/<user>/<repository> my_project

I share my solution.

Upvotes: 3

Related Questions