Reputation: 16857
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
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
Reputation: 41
Upvotes: 2
Reputation: 453
Generate an access token in GitHub from Settings → Developer settings → Personal Access Tokens → Classic tokens → Generate 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
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
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
Reputation: 1396
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
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 Settings → Developer Settings → Personal Access Token → Tokens (classic) → Generate New Token (Give your password) → Fillup the form → click Generate token → Copy 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 Panel → Windows Credentials → find
git:https://github.com
→ Edit → On Password replace with with your GitHub Personal Access Token → You are DoneIf you don’t find
git:https://github.com
→ Click on Add a generic credential → Internet address will begit: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 forgithub.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
- Press ⌘Сmd0/CtrlAlt0 (your actual key-binds may differ), to open settings and then select Version Control | GitHub.
- Click the Add button.
- Select Log In with Token.
- The token can then be inserted into the following text-field:
- Click Add Account
Upvotes: 2243
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:
On GitHub, Go to Settings > Developer Settings. Then generate an access token.
Run git remote add origin <repo_url>
Run git remote set-url origin https://<TOKEN>@github.com/<user_name>/<repo_name>.git
Run git clone https://github.com/<repo_url>.git
Asks for username and password. Put your GitHub username and generated access token (as password) in respective places.
Upvotes: 2
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 Panel → User Accounts → Manage your credentials → Windows 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
Reputation: 7190
Keychain Access
.github.com
(if there are multiple GitHub logins then choose Kind: Internet password
), double-click it.And that's it. Enjoy!
github.com
and edit the password with the token
you have generated on GitHub.
Now enjoy!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.
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
Reputation: 2091
Create a personal access token (PAT) for your account. See here to create your PAT. Your PAT should start with ghp_
Open your Keychain Access app, search for GitHub, and delete your existing saved passwords
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
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
Reputation: 53
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.
Upvotes: 3
Reputation: 244
I'm a Sourcetree user and fixed it by "Refresh OAuth Token" in menu Tools → Options → Authentication → select GitHub Account.
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
Reputation: 747
First you need SSH Key Based Authentication
And then
git config --global user.name "userName"
git config --global user.email "email"
git config --global credential.helper cache
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
Reputation:
Simplest solution (May 2022):
git push
Upvotes: 70
Reputation: 6374
Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
Create a GitHub personal access token (PAT) and copy it.
For macOS, add it to KeyChain Access under GitHub.
Spotlight Search → type KeyChain → select KeyChain Access → search for github.com → paste your PAT
For Windows, add the PAT to Windows credentials for your user.
Search → type Credential Manager → Add your PAT to github.com
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.
git clone
as usual :-)
Upvotes: 4
Reputation: 1047
(I have taken this part from Kartik Tyagi, but I added one of the crucial part that has been missed.)
Keychain Access
.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.
And that should be it. Enjoy!
Upvotes: 3
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
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
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
Reputation: 411
Get an access token from GitHub:
GitHub → Settings → Developer settings → Personal access tokens → Generate 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
Reputation: 7636
(e.g., Settings > Developer Settings > Personal Access Token)
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,
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
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:
Generated the PAT and used as password - it didn't work.
Cleared the github.com entry in the Windows Credential Manager - not working.
Added the PAT to the repository URL like this
https://<personal-access-token>@github.com/<my-repo-url>
Restarted PC. Installed the newest Git from https://git-scm.com - and in Sourcetree - menu Tools → Options → Git → Git Version - selected "System".
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
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.
Upvotes: 16
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
Reputation: 3635
If you're using macOS and do not find the github.com entry in the KeyChain access:
Upvotes: 15
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
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
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