Message "Support for password authentication was removed."
Asked Answered
F

50

1664

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?

Finespun answered 13/8, 2021 at 16:49 Comment(1)
Sometimes it uses ssh-askpass tool from SSH_ASKPASS env variable and stores the password in wallet. To overcome this either change/remove the values in wallet or unset SSH_ASKPASSHaase
S
2087

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 PhpStorm

If you are using PhpStorm, go to menu Gitpull and select authentication via Personal Access Token. Enter your PAT it will allow you to pull/push the changes.

Stoughton answered 14/8, 2021 at 6:58 Comment(53)
Be sure to save the token on some local file or in some cloud.Upvoted.Dollarfish
Given that the OP states they already created a token two weeks ago, this doesn't address the actual problem.Haematozoon
@Dollarfish Save it in a password manager, with all the security that comes around with that. Not in some random unprotected file.Sedimentary
Ummmm, it isn't asking for a token when I clone my repo, how should I proceed then?Laird
@Laird I think you can clone public repo without password, but not private repoStoughton
Same experience as @Prhyme. I am not able to get git to prompt me for username and password, even trying to clone private repos, push to repos, etc. When I go to push to a repo, it continues to give the "Support for password authentication was removed" message, without prompting for anything.Confectioner
You definitely do not want to delete your GitHub password from macOS's Keychain, the "internet password" entry is the saved password from Safari.Ivonne
In Mac, I open keychain and find that github item, but how could I change the password with token?Wurster
@CHUCKZHB This can help docs.github.com/en/get-started/getting-started-with-git/…Stoughton
command git config --global credential.helper store is for who want to permanent store their token. The token will be store in your disk. This method is the easiest but not safe at all.Inhospitable
Notice on mac: Direct search&delete the github key cannot work on my mac. Please try to select Local items on the sidebar then do the search&delete, this would be fineRemontant
Does not answer the question. See the answer from @ßãlãjî belowLallans
in macOS, delete github item in key chain not work. but use For Linux based OS method unset credential.helper work.Pongid
in macOS, delete github item in key chain not work. but use For Linux based OS method unset credential.helper work.Pongid
It didn't work for me on Ubuntu. I tried to pull a branch but it kept showing the same error.Meader
That was awesome - would have taken me a while to get that old one replaced in OS X. Thanks!Rubicon
What if several people use the same Windows account to push data under different github profiles?Ligetti
@Ligetti you can use the same Windows account to push data under different github profilesStoughton
For mac first time, when you are prompted for a password when you pushing the code to your repo, enter the access token, It will add the token in the keychain and it won't prompt again.Roee
Wouldn't the git config option cause problems if you use Github and Gitlab? Would you have to change those every time you pushed to one or the other? Is there a cleaner way?Hancock
@Hancock this is for Github, you need to setup the PAT one time not every timeStoughton
@sta right, but then wouldn't your commit email / username show as [email protected] on Gitlab?Hancock
@Hancock you can keep your email addresses private on your commits, check thisStoughton
@sta Right, Github uses a different email address than Gitlab for that. If I set my user preferences in Git to one site, it will break the other one.Hancock
but it keep asking the username & password eventough i already set it the credential under control panel (windows).... what is missing for this matter?Vermilion
I have a breaking bug in my Keychain access so I used the Linux terminal commands instead, it worked perfectly on my Mac OS.Cholecystectomy
Might be obvious but you need to check the "repo" checkbox when creating the token. I found it a little misleading that "read and write code to repo" is not a sub-option of the main "repo" checkbox.Roughhouse
username command not found when typed: Username for 'https://github.com' : usernameNerissa
I updated it with a token and github pages (jekyll) keeps on asking me for login and password whenI deploy new branch...Hexose
I don't find any "Developer Settings" in "Settings" in my Github AccountLongsighted
In case people are struggling to find the Developer Settings tab -> github.com/settings/tokensHarassed
Also when generating personal token, remember to check all the necessary permission on github or access might get denied.Aster
why do I get username not found when I do the token part on linux?Clatter
what exactly means "edit or delete accordingly"? which one of thousands github entries I should edit? What fields to edit?Bioluminescence
When I try enter password I got same error ?Wrangler
Save the key in notes files realy handy, but that configuration command does the job for not asking for password again and againFelic
@ßãlãjî answer is better I think!. For mac it will repo based control rather.Vascular
why not use password authentication? forcing users to opt from this kind of procedureCartwright
@ajgo password authentication is no longer available for Github, use Personal Access Token insteadStoughton
@sta - yes, but why they force to use that?Cartwright
@ajgo it's a high security issueStoughton
@sta - so its disappointing that their authentication for passwords is that vulnerableCartwright
What does this mean? "Find the internet password entry for github.com " I already put in my GitHub password and got the authentication message! ??Avron
@Avron that line is based on Github official documentation, here docs.github.com/en/get-started/getting-started-with-git/…Stoughton
Not working for UbuntuRheims
This is, not surprisingly, plagiarised on Medium (wholesale copy-pasted). This is listed together with two other pages in the reference section, but that doesn't make it less plagiarised. It also plagiarises those two other pages (wholesale copy-paste).Protrusive
my cmder is still asking me for my username and password after doing the above steps on windowsKendre
It looks like git config --global credential.helper cache cannot save the key between boots?Sealer
you should add that the sudo command is required for the linux commandsClatter
In the above Personal Access Token, just remember to give Read / Write permission to all your repositories and all repositories / number of days and just public repository / All and you would need to give access manually from respective drop after expanding. You could compare after reading below that how many of your repositories and what permissions are given. Cheers.Africa
For WSL users see this stackoverflow post.Kierkegaardian
this helps me and save my time thanks for detail and proper explaination .Arsonist
if the github API token has expired, with the token-as-username login, git will ask for a password. if the github API token has expired, with the token-as-passoword login, git will say remote: Support for password authentication was removed on August 13, 2021. these are bugs in github.Scabrous
P
591

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.

Pilliwinks answered 14/8, 2021 at 4:46 Comment(15)
I found that on Windows, it was necessary to delete the existing credential in the credential manager. Then, the next time I tried to do a git push, it prompted for the Personal Access Token. Simply resetting the existing credential did not work.Bay
This option worked for me. I was struggling to push to an existing repository and after changing the password with the key, it works.Loony
For me, credential manager didn't update. I had to remove the entry. on the next pull a popup appeared asking for PAT, I entered it and it was saved anew.Unrelenting
The developer hack worked good for me (I go between Github, Gitlab, and multiple accounts on each site) but it seems to me that this is a major security downgrade from just typing in a password, each one of these repos can push directly to Github without asking for a password at all; how is this safer?Hancock
If you use Firefox, probably there is no github.com password in Keychain. In this case just log in to github.com with SafariKarolyn
For those who does not have this entry: it should 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.Benioff
That didn't work for me. rodmclaughlin.com/…Competence
using the generated token as github password on terminal screen.Crick
@DarkNeuron 1. In Keychain Access, make sure you're viewing 'All Items' i.e. it shouldn't be set to certificate, keys, otherwise you won't see it. 2. The 'developer's hack' way created the entry and added the token, so no other work was needed by meBailar
Search for github.com (if there are multiple GitHub logins then choose Kind: Internet password), double-click it. this doesn't ever show upDrysalter
If you don't have github.com in Keychain, simply push a commit to github in your command line. It will ask for your username and password. Enter your username, and use the personal access token you just created as your password.Earphone
The developer hack of simply doing git remote set-url origin worked perfectly for me. You can also confirm if the change made it through gits config by looking at the "remote.origin.url=" field when you do git config --listPratt
I have tried both my Mac password and the Github password in keychain and neither work.Avron
doesn't work for sourcetreeMidian
life saver hackHelles
F
386

Use My AccountSettingsDeveloper settingsPersonal access tokensGenerate new token.

git remote set-url origin https://<token>@github.com/<username>/<repo>
Fetch answered 14/8, 2021 at 9:5 Comment(14)
Note that this seems to require running this command in each repo for that repo to be reset with the new credentials. Hopefully there is a global solution.Confectioner
This one perfectly worked for me. The above one with maximum vote didn't work.Jarlen
But with a token anybody with this token can push to your repo. In a public computer how would you keep the password protection?Zimmermann
Thanks! Using token as password not work, but adding this work awesomeDustin
This is very insecure, not only does it allow anyone on the local system with read access to the local repo control over that repo, git remote -v simply discloses the key giving the attacker account wide access to your GitHub account.Nieman
@ßãlãjî OS key managers and browsers take grate pains to secure credentials. Normal git workflow do not expose passwords or ssh private keys to other users with read access to a repo. The above advice does. It allows anyone with read access to a copy of a local repo, including for example a shared work or school filesystem, to see the user's clear text Personal Access Token. This extends to archived copies as well, such as source tarballs that retain the .git directory.Nieman
If you are working on someone else's repo, replace the <username> with their own (the one found at the URL, right after "github.com" and before the following "/")Forensics
It still asks for a password even with the token in the url: Password for 'https://<token>@github.com': remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.Eldwen
this works for me if i don't put in the <username>, so git clone https://<token>@github.com/<repo>Repand
The only way it works for me (mac os) is this command, but I need to generate a new token for each repo. when reusing the same token with different repos i get prompted to use password. what a messKarisakarissa
fatal: No such remote 'origin'Staphylo
@Xu shan your URL must be a wrong Check correctly once again and submitFetch
doesn't work for me, still asks for passwordRimbaud
if the github API token has expired, with the token-as-username login, git will ask for a password. if the github API token has expired, with the token-as-passoword login, git will say remote: Support for password authentication was removed on August 13, 2021. these are bugs in github.Scabrous
V
226

For Linux these simple steps can solve your problem

  1. If your Git password is cached in credential.helper, then unset it:

    git config --local --unset credential.helper
    

    Or, If you have set your credentials globally, then:

    git config --global --unset credential.helper
    
  2. Now go to your GitHub Account settings

    Enter image description here

  3. Click Developer Settings

    Enter image description here

  4. Select Personal Access

    Enter image description here

  5. Generate a token with the given permissions, e.g.,

    Enter image description here

  6. Now git pull inside your Git repository

  7. Provide a username and the generated token as a password

Enter image description here

That is a straightforward solution step by step.

PS: If you are annoyed by Git asking for username/token again and again, follow these three simple steps

  • Run nano ~/.git-credentials. Remove the GitHub line and save it.

  • git config --global credential.helper store

    Risky as physically the token is saved in file ~/.git-credentials

  • Run git pull and provide the username and password only once

It will not ask for the username and access token again and again now!

Valuer answered 14/8, 2021 at 8:51 Comment(10)
Those are a lot of permissions. What are you using that token for?Sedimentary
It all depends on the use case you want to use that token for. So select those permissions according to your use case.Valuer
It only worked when I followed this.Priestess
Is there a way to save it to a custom location? Perhaps it can help reduce the risk?Fallow
Do NOT do that with permissions.Ghiselin
Thanks a LOT <3 your command prompt screenshot helped and worked like charm. I simply used the token as password even in SmartGit.Thaumaturge
This method did work, thank you. To be sure, if we do not want the token saved in plain text currently, the only solution is to either memorize the ssh token or go to github whenever we want to push a change?Philippopolis
I just did Regenerate token, and then follow step 6-7Anarchy
@LeandroBardelli can you explain why they should not follow that permission?Gastrulation
@AdrianGaileSingh permissions should be granted in "NONE to specifics" not in "ALL but specifics". Do not give permissions that you wont need never. even more if the process is automated.Ghiselin
C
203

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.

Cindicindie answered 14/8, 2021 at 11:3 Comment(0)
W
106

This message means that you're using a password instead of a personal access token to access GitHub over HTTPS, and that's no longer allowed. GitHub has disabled password authentication because it's common for people to accidentally leak their passwords, and while a personal access token can be restricted to limit the damage, a password cannot.

If you haven't explicitly entered your password at a prompt, then it's likely you have a credential manager which is saving your password and sending it without prompting you.

You can follow the directions for clearing your credential manager listed in the Git FAQ:

$ echo url=https://[email protected] | git credential reject

You should use this same URL, but replace account with your own username (e.g., in my case, it would look like echo url=https://[email protected]).

Then, the next time you try to push or pull, Git will prompt you for a username and password. For the username, enter your GitHub username, and for the password, generate a new personal access token on the appropriate settings page and paste it into the password field. If you're working from the command line, you may not see any indication that the password was successfully pasted; this is normal, so just hit Enter afterwards.

That will save the personal access token in your credential manager for the next time, assuming you have one set up. If you're not sure if you have one set up, run git config credential.helper and see if it outputs anything.

If you don't have one set up, you should add one so that you don't have to memorize your token. Run one of the following commands, depending on operating system:

  • git config --global credential.helper manager on Windows;
  • git config --global credential.helper osxkeychain on macOS;
  • git config --global credential.helper libsecret on Linux (if available); or
  • git config --global credential.helper store on Linux if libsecret isn't available.

Then you can try the push or pull again until you're no longer prompted.

Wabash answered 13/8, 2021 at 17:1 Comment(7)
Thanks for the info, I just tested git config --global credential.helper osxkeychain and git config --global credential.helper but nothing is happening in my console, so I will try the first solution. Just one question, what is the url=https://[email protected]? The link of my repot or my github?Finespun
check out #68776800 to change the password on a macFoliaceous
The technique I've mentioned above will clear the password on any system so Git will prompt for it again. That's why we documented it in the FAQ, because the directions are different for each individual OS and credential helper and it's too hard to write a single answer that applies to all systems when it involves the GUI.Wabash
echo url=https://[email protected] | git credential reject was just what I needed. Thank you!Horoscope
This was the way to fix things, thanks! Apparently I had done everything right according to the numberous reminders, but nowhere did it actually say how to start using the tokens...Easley
Thanks buddy. I knew it already but kept on forgetting it as I don't put code on github generally.Disaccustom
Still getting remote: Support for password authentication was removed on August 13, 2021.Proliferate
L
68

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
Lollard answered 29/1, 2022 at 19:3 Comment(1)
I cannot verify that this all that is needed, but I it very well might. You see, based on answers above I put the PAT into the Keychain Access (Mac) and then I pasted the PAT for password on the command line when prompted during my 'git clone' command. Maybe I didn't need to put PAT in Keychain Access. I can say that if I do another clone I am not prompted for auth. If this answer is all one needs to do then this is the best answer.Loreeloreen
M
43

Generate an access token in GitHub from SettingsDeveloper settings.

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

If you are going to clone repository after 13 August 2021, then you can use the normal clone command and set the generated access token in the password field.

Michaelemichaelina answered 14/8, 2021 at 14:41 Comment(3)
And it should be "<repo>.git".Conglutinate
If you're like me and have years worth of git repos that you used password based auth on. I have made this: find . -type f -path '*/.git/*' -name 'config' -exec sed -i 's%https://github.com/%[email protected]:%g' {} \; It will recursively search in the .git folder for any file called config and find and replace the https URL with the git@github one. I'd recommend only doing this on simple repos where you know you have plain vanilla remotes. I haven't tested how it will work on different setups. YMMV!Lodgings
I tried removing the username and it worked: git remote set-url origin https://<token>@github.com/<repo>.gitTina
B
34

For Ubuntu, use the following steps

Blacksnake answered 14/8, 2021 at 17:29 Comment(0)
I
24

A one-command simple solution to solve it

If your computer has no SSH key added to the GitHub account, I add information for you to do it at the end of the answer. You should do it first.

After push failed, then do this:

git remote set-url origin [email protected]:{user_id}/{project_name}.git

And push again. Then it works.

Let me show my case in the following.
(And I will guide you on how to do your case.)

At the first, when I add, commit, and push, then I meet this issue:

Enter image description here

And then, my current Git log is the following.

Enter image description here

In the final, this is my way to solve the issue.

Enter image description here

In my case,

  1. {project_name} <-> open-idea-pool

  2. {user_id} <-> milochen0418 is the

  3. {branch_name} <-> master

(your branch_name maybe is main, but not master)

When I push failed, the only thing I need is this one command:

git remote set-url origin [email protected]:{user_id}/{project_name}.git

Then I push it again by:

git push -u origin {branch_name}

For the example of my case,

git remote set-url origin [email protected]:milochen0418/open-idea-pool.git
git push -u origin master

It works.

-- By the way, this is the process of creating an SSH key to GitHub account.

You can refer to these two links to do it. The information here supports Mac, Windows, and Linux.

  1. Issue on adding SSH key to GitHub
  2. Adding a new SSH key to your GitHub account

Furthermore, if you want to clone a new project, you can do the following command:

git clone [email protected]:{user_id}/{project_name}.git
Inquietude answered 14/8, 2021 at 14:7 Comment(6)
I bet this works only because you have an SSH key added to the github account.Jocularity
Maybe add the process of creating an SSH key to the answer?Jocularity
Thanks a lot. I will add some simple processes of creating an SSH key tomorrow. GitHub official doc also introduces how to do it, but that's is too complicated for junior people.Inquietude
I've done to add the process of creating an SSH key to github account by refer two excellent links.Inquietude
Advisable to use ssh instead of using username/password(token) approach. Good answer. Instead of https://github.com/<repo_url> use [email protected]:<repo_url>Trucker
Please review Why not upload images of code/errors when asking a question? (e.g., "Images should only be used to illustrate problems that can't be made clear in any other way, such as to provide screenshots of a user interface.") and do the right thing (it covers terminal sessions as well). Thanks in advance.Protrusive
S
16

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

git config --global url."[email protected]:".insteadOf "https://github.com/"
Solarize answered 21/4, 2022 at 1:3 Comment(4)
this is actually the easiest solution; i wonder if there is no caveats in thisUnderscore
SSH is even safer than HTTPS for authentication because you'll never need to send your secret over the internet. The other part (git server in this case) only knows your public key and you just need to keep safe your private key in your machine. That's why strong authentication use such approach. You could also protect your private key with something like chmod 400 your_key. Where 4 is the permission for you to read only your key without the risk of modifying it and 0 permissions on your secret for any user in your group and 0 for the rest of the world as well.Solarize
I had the same symptoms as OP, and this answer solved it for me, i.e opening the Git config file and replace the HTTPS address with the SSH one.Flyleaf
This had to be the answer with the most votes...Paschall
G
15

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

Gyrostatics answered 16/11, 2021 at 16:5 Comment(0)
H
15

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
Hauser answered 2/12, 2021 at 2:59 Comment(0)
T
12

Go to SettingsDeveloper settings → generate a new token if it does not exist.

Or copy the token if it exists.

Enter image description here

Then set the token:

git remote set-url origin https://<token>@github.com/<username>/<repo>.git/
Tympanist answered 22/8, 2021 at 13:53 Comment(0)
B
12

First create the token on GitHub:

  1. Click on the profile picture and in the menu select Settings
  2. Select Developer Settings in the left menu at the bottom
  3. Select Personal Access tokens in the left menu (third option)
  4. Select Generate new token and follow the next steps.

If you have not installed GitHub CLI, you would not find it in your keychain Access. Therefore you should install it first.

  1. Install GitHub CLI for macOS

    brew install gh
    

    For Windows:

    winget install gh
    scoop install gh
    choco install gh
    
  2. On the command line, enter gh auth login, follow the prompts, and provide the following answers

    ? What account do you want to log into? GitHub.com

    ? What is your preferred protocol for Git operations? HTTPS

    ? Authenticate Git with your GitHub credentials? Yes

    ? How would you like to authenticate GitHub CLI? Paste an authentication token

  3. Paste the token you created on GitHub and press Enter.

Bluegrass answered 4/9, 2021 at 10:1 Comment(0)
S
9

Generating a GitHub personal access token (PAT)

  1. Log in to your GitHub account and open SettingsDeveloper Settings Personal Access Tokens.
  2. Click on Generate New Token.

Do not forget to copy and the token after generation. It is accessible only once.

Windows

  1. Open Control PanelUser AccountsCredential Manager.
  2. Now, look for git:https://github.com.
  3. Click on Edit.
  4. Replace the password with the GitHub Personal Access Token.

MAC

  1. Click on Spotlight Icon and search for Keychain Access.
  2. Inside Keychain Access, search for github.com.
  3. Now, look for the internet password entry for github.com.
  4. Update the entry.
Selfwinding answered 14/8, 2021 at 11:40 Comment(1)
I found that on Windows, it was necessary to delete the existing credential in the credential manager. Then, the next time I tried to do a git push, it prompted for the Personal Access Token. Simply resetting the existing credential did not work.Bay
Q
9

Mac users -- a simple solution.

Set up the personal access token in GitHub:

SettingsDeveloper SettingsPersonal access token

Open Keychain → type "GitHub"

Change the password to the personal access token.

Try commit/pushing.

Select "Always allow" and business is as usual.

Quintana answered 14/8, 2021 at 17:14 Comment(0)
D
9

I was using git pull on Linux with a password before.

If that is the case, the only thing you need to do is use token in place of password.

Generate an access token by going to Personal access tokens.

Here is example of git pull

git pull

Username for 'https://github.com': gitusername
Password for 'https://[email protected]': //Then enter generated token
Debacle answered 2/9, 2021 at 9:28 Comment(1)
In my case after doing "git pull", just do "git pull" a second time and you should get prompted for the username and password automatically. It shouldn't require you go to delete your password in the OS settings.Psychophysiology
P
8

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.

Portraitist answered 4/12, 2021 at 20:4 Comment(1)
git clone GIT_USER_NAME:<your_token>@github.com/username/repo.gitAlliteration
G
7

If you want to clone for the first time:

git clone https://<repository_owner>:<personal_access_token>@github.com/<repository_owner>/<repo>.git
Geneviegenevieve answered 5/11, 2021 at 15:40 Comment(0)
M
6

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:[email protected]/username/private-repo.git
Marietta answered 27/11, 2021 at 5:51 Comment(0)
R
4

In Linux, you can generate a new access token in GitHub and directly replace it in place of the password in the ~.git-credentials file.

The password section starts with : and ends with @.

Rna answered 14/8, 2021 at 17:2 Comment(0)
S
4

A quick solution for Windows users

Open Credential Manager and just remove the already-saved credentials for Git: https://github.com.

Enter image description here

After this step, run the command again for pull/push in the terminal. GitHub will ask to log in with your default browser automatically (make sure you are logged in with GitHub in the default browser).

Enter image description here

After successful login, we got this message:

Enter image description here

For more help related to this, you can also watch this video.

Synodic answered 20/8, 2021 at 14:56 Comment(0)
H
4

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

Helvellyn answered 16/2, 2022 at 21:35 Comment(0)
I
4

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

git clone https://your_username:[email protected]/username/private-repo.git
Illstarred answered 14/4, 2022 at 6:16 Comment(1)
This is the most useful answer for me. The original poster (like me) already had a token - it just did not work as expected. All the answers starting with "generate a token" are therefore a bit beside the point. My existing token works fine in other places, so I don't see the need to start all over again. And all the answers based on git remote set-url store your token in a way that is not terribly secure. My repo wouldn't accept the token at the password prompt, even with a fresh clone, but this worked. Afterwards I just deleted the line from the bash history - no spillage :-)Swede
F
3

Android Studio Arctic Fox Solution (Windows 10)

I was authenticated in Android Studio 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 worked finally!

Facsimile answered 14/8, 2021 at 9:31 Comment(0)
D
3

Run these commands inside your project directory if the project was cloned before 13 Aug 2020:

git remote set-url <remote_name> <remote_url>
git pull

Type your username and personal access token as the password.

Dross answered 14/8, 2021 at 18:17 Comment(1)
Example - git remote set-url origin github.com/myName/GitTest.gitAdalai
B
3

As a security precaution, GitHub automatically removes personal access tokens that haven't been used in a year. To provide additional security, we highly recommend adding expiration to your personal access tokens.

Just follow Creating a token.

Bainmarie answered 19/8, 2021 at 11:30 Comment(0)
P
3

In three commands:

First create a token as indicated in the official documentation: Creating a personal access token

Then reset the Git credentials

git config --global --unset credential.helper

Clone or pull your repositories:

`git pull` or `git clone`

Then enter the token as your password.

If you want to save your token, you can use:

git config --global credential.helper cache
Paxwax answered 19/8, 2021 at 19:0 Comment(0)
W
3

For Mac users

Generate a token and set it in the keychain.

This quick video explains it well.

For Windows Users

Just instead of the keychain, you need to set up Credential Manager with the newly generated token.

Here is a quick video for Windows

Warnock answered 20/8, 2021 at 5:10 Comment(0)
L
3

Recently GitHub updated their remote: Support for password authentication. Which was removed on August 13, 2021 to use PAT (personal access token) instead for accessing the GitHub API.

You can read about in the blog post here.

Now to enable PAT

  • Log in to your GitHub account.
  • Follow this write-up for the next actions.

Now to use the token on the command line, do this:

git clone https://github.com/username/repo.git

Username: your_username
Password: your_token

Note that your token has an expiry time and must be kept privately and used whenever you need to authenticate on the command line.

Heads up

If your are cloning into a repository that is owned by an:

Organisation

  • Make sure your are member of that organisation

Or if some personal repository,

  • Make sure you have enabled the following

The organisation/personal will need to enable remote cloning and forking like so:

  • Go to organisation settings:

Settings page

  • Enable member privileges:

    Member privileges page

Leroi answered 2/9, 2021 at 10:41 Comment(0)
W
3

For people who want to use Sourcetree:

Just copy like this at the source path:

https://<token>@github.com/<username>/<repo>

Add like your repository like this to the source path

Worthless answered 4/9, 2021 at 7:28 Comment(1)
You can authenticate in 3 ways: * Method 1: using gh auth login. * Method 2: using tokens, but they are temporary and have an expiration date. * Method 3: using SSH keys. Personally, I like to use SSH keys better, here is a video on how to do it. youtube.com/watch?v=gbF6b5Xfh3sPreconcerted
K
3

The best solution I have found so far:

  1. Install GitHub CLI, brew install gh or check how to install for other OSes

  2. Type gh auth login in your terminal

  3. Follow through like this:

    What account do you want to log into?
    Choose GitHub.com
    
    What is your preferred protocol for Git operations?
    Choose HTTPS
    
    Authenticate Git with your GitHub credentials?
    Choose Yes
    
    How would you like to authenticate GitHub CLI?
    Choose Login with a web browser
    
    (Copy the one-time code and paste in the browser)
    
    Press 'Enter' to open github.com in your browser
    
Kaden answered 4/9, 2021 at 8:48 Comment(1)
In case someone is looking for way to install brew on Arch based distros: gist.github.com/fardjad/114ebf50a0dd031418bb63b3b134db51Suggestive
O
3

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.

Oracular answered 22/9, 2021 at 15:46 Comment(0)
S
3

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

Sleepy answered 17/7, 2022 at 3:38 Comment(2)
What do you mean by "something last time need user name and password" (is incomprehensible)? For instance, is punctuation missing? Are words missing?Protrusive
it means next time no need to type the user name and password again,Sleepy
O
2

For those who followed the instruction to generate the Personal access tokens, but forgot to select suitable scopes:

Please do remember to choose suitable scopes like repositories. You won't get a different error prompt whether you use the previous password or a new token without a suitable scope.

Ormsby answered 20/8, 2021 at 9:51 Comment(1)
Re "choose suitable scopes like repositories" (seems incomprehensible): Do you mean "choose suitable scopes for repositories"? Or something else? Please respond by editing (changing) your answer, not here in comments (without "Edit:", "Update:", or similar - the answer should appear as if it was written today).Protrusive
B
2

For anyone who uses Sourcetree as the Git client, open Preferencesgo to the Accounts tabAdd GitHub accountAuth type = basic → fill in your GitHub account and the access tokens from GitHub you created as a password → Use HTTPS protocol → done!

Bedspread answered 23/8, 2021 at 6:6 Comment(0)
A
2
  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: [email protected]: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.)

Amanuensis answered 14/2, 2022 at 2:7 Comment(1)
In addition: git config --global url."[email protected]:".insteadOf "github.com"Solarize
A
2

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!

Autoionization answered 13/4, 2022 at 13:44 Comment(2)
This does not work. After I do all the steps, running the command git push -u origin main on Mac prompts for Username, which I provided, and then Password. At the Password prompt, I tried by pasting (cmd+V) and [Enter], and that worked.Cortez
High likely I forgot to add this part here. Thanks for mentioning.Autoionization
R
1

Yesterday I had some issues trying to find GitHub on the Keychain in my MacBook. I've tried a lot of ways with no success.

From my perspective, the workaround I've used to be able to pull and push from my GitHub account fast, was doing it by SSH.

This allowed me to do it with no further configuration.

  1. You can do it going to SSH keys
  2. Then New SSH key
  3. If you already created an SSH locally, just run pbcopy < ~/.ssh/id_rsa.pub in your terminal
  4. Then pull, push, clone or whatever you need from your GitHub repository and it's done

I know this is not the solution to the issue, but it worked for me since I needed to do it fast and to me to be honest there isn't any reason that I need to use HTTPS instead of SSH.

Represent answered 19/9, 2021 at 20:9 Comment(1)
Can you provide more details? Do you already have a ssh generated? Also, make sure when you are cloning the repo you change. HTTPS to SSHRepresent
D
1
  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.

Dion answered 11/10, 2021 at 15:57 Comment(1)
Why should it start with "ghp_"?Protrusive
S
1

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://[email protected]': (enter your token here)
Scanderbeg answered 14/6, 2022 at 13:31 Comment(1)
On Windows, presumably (the last part)?Protrusive
U
1

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

Ulrica answered 5/9, 2022 at 5:59 Comment(0)
S
0

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.

Shaitan answered 20/10, 2021 at 9:18 Comment(0)
M
0

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.

Mopup answered 3/11, 2021 at 12:32 Comment(0)
S
0

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
Skinnydip answered 13/6, 2022 at 20:7 Comment(1)
What is "GH"? The GitHub desktop application? Or something else?Protrusive
M
0

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 repo's 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 repo:

[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>/

Tested and works very nicely.

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

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.

Mover answered 2/3, 2023 at 23:14 Comment(0)
J
0

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.

Joella answered 31/1 at 7:53 Comment(0)
S
-1

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

Stricken answered 4/10, 2022 at 15:38 Comment(0)
D
-1

I changed my default browser from Google Chrome to Safari and it fixed it.

Dogcart answered 4/7, 2023 at 8:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.