Github failed to Authentication [duplicate] - github
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. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: unable to access "..." : The requested URL returned error: 403
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?
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 → 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 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 Git → pull and select authentication via Personal Access Token. Enter your PAT it will allow you to pull/push the changes.
If you're using macOS, just simply follow these steps:
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)
Generate a new token and copy-paste it somewhere safely.
Now search for an app in your Mac, named Keychain Access.
Search for github.com (if there are multiple GitHub logins then choose Kind: Internet password), double-click it.
Click on show password, then enter your Mac's password and hit Enter.
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:
Follow steps 1 and 2 as above.
Search for an application in your Windows OS, named Credential Manager → then Windows Credentials.
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.
Use My Account → Settings → Developer settings → Personal access tokens → Generate new token.
git remote set-url origin https://<token>#github.com/<username>/<repo>
For Linux these simple steps can solve your problem
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
Now go to your GitHub Account settings
Click Developer Settings
Select Personal Access
Generate a token with the given permissions, e.g.,
Now git pull inside your Git repository
Provide a username and the generated token as a password
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!
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.
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://account#github.com | 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://bk2204#github.com).
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.
Simplest solution (May 2022):
Create a new token at Personal access tokens
Copy token (Windows: Ctrl + C, macOS: Cmd + C, or click copy icon)
Try to push your local repository: git push
Enter your GitHub user name
Paste the token as your password
Generate an access token in GitHub from Settings → Developer 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.
For Ubuntu, use the following steps
At https://github.com/settings/tokens, go and generate a token.
git push
username: user_github_username
password: add_generated_token instead of the password.
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 git#github.com:{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:
And then, my current Git log is the following.
In the final, this is my way to solve the issue.
In my case,
{project_name} <-> open-idea-pool
{user_id} <-> milochen0418 is the
{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 git#github.com:{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 git#github.com: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.
Issue on adding SSH key to GitHub
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 git#github.com:{user_id}/{project_name}.git
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
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.
First create the token on GitHub:
Click on the profile picture and in the menu select Settings
Select Developer Settings in the left menu at the bottom
Select Personal Access tokens in the left menu (third option)
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.
Install GitHub CLI for macOS
brew install gh
For Windows:
winget install gh
scoop install gh
choco install gh
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
Paste the token you created on GitHub and press Enter.
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://yourusername#github.com': //Then enter generated token
Generating a GitHub personal access token (PAT)
Log in to your GitHub account and open Settings → Developer Settings
Personal Access Tokens.
Click on Generate New Token.
Do not forget to copy and the token after generation. It is accessible only once.
Windows
Open Control Panel → User Accounts → Credential Manager.
Now, look for git:https://github.com.
Click on Edit.
Replace the password with the GitHub Personal Access Token.
MAC
Click on Spotlight Icon and search for Keychain Access.
Inside Keychain Access, search for github.com.
Now, look for the internet password entry for github.com.
Update the entry.
Go to Settings → Developer settings → generate a new token if it does not exist.
Or copy the token if it exists.
Then set the token:
git remote set-url origin https://<token>#github.com/<username>/<repo>.git/
Mac users -- a simple solution.
Set up the personal access token in GitHub:
Settings → Developer Settings → Personal 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.
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.
You can force your machine to just use SSH instead of HTTPS:
git config --global url."git#github.com:".insteadOf "https://github.com/"
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
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 #.
A quick solution for Windows users
Open Credential Manager and just remove the already-saved credentials for Git: https://github.com.
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).
After successful login, we got this message:
For more help related to this, you can also watch this video.
The best solution I have found so far:
Install GitHub CLI, brew install gh or check how to install for other OSes
Type gh auth login in your terminal
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
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.
Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
Solution
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 :-)
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.
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
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
First you need SSH Key Based Authentication
Windows Tutorial: SSH Key Authentication
Linux/Mac Tutorial: SSH Key-Based Authentication
Documentation
And then
Generate a personal token
Set your user name: git config --global user.name "userName"
Set your email address: 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
If you want to clone for the first time:
git clone https://<repository_owner>:<personal_access_token>#github.com/<repository_owner>/<repo>.git
Related
I'm new to github and I'm trying to push my new local repository to github , but it keeps giving me an authentication error, Im sure of my password [duplicate]
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. Please use a personal access token instead. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information. fatal: unable to access "..." : The requested URL returned error: 403 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?
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 → 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 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 Git → pull and select authentication via Personal Access Token. Enter your PAT it will allow you to pull/push the changes.
If you're using macOS, just simply follow these steps: 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) Generate a new token and copy-paste it somewhere safely. Now search for an app in your Mac, named Keychain Access. Search for github.com (if there are multiple GitHub logins then choose Kind: Internet password), double-click it. Click on show password, then enter your Mac's password and hit Enter. 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: Follow steps 1 and 2 as above. Search for an application in your Windows OS, named Credential Manager → then Windows Credentials. 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.
Use My Account → Settings → Developer settings → Personal access tokens → Generate new token. git remote set-url origin https://<token>#github.com/<username>/<repo>
For Linux these simple steps can solve your problem 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 Now go to your GitHub Account settings Click Developer Settings Select Personal Access Generate a token with the given permissions, e.g., Now git pull inside your Git repository Provide a username and the generated token as a password 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!
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.
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://account#github.com | 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://bk2204#github.com). 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.
Simplest solution (May 2022): Create a new token at Personal access tokens Copy token (Windows: Ctrl + C, macOS: Cmd + C, or click copy icon) Try to push your local repository: git push Enter your GitHub user name Paste the token as your password
Generate an access token in GitHub from Settings → Developer 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.
For Ubuntu, use the following steps At https://github.com/settings/tokens, go and generate a token. git push username: user_github_username password: add_generated_token instead of the password.
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 git#github.com:{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: And then, my current Git log is the following. In the final, this is my way to solve the issue. In my case, {project_name} <-> open-idea-pool {user_id} <-> milochen0418 is the {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 git#github.com:{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 git#github.com: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. Issue on adding SSH key to GitHub 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 git#github.com:{user_id}/{project_name}.git
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
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.
First create the token on GitHub: Click on the profile picture and in the menu select Settings Select Developer Settings in the left menu at the bottom Select Personal Access tokens in the left menu (third option) 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. Install GitHub CLI for macOS brew install gh For Windows: winget install gh scoop install gh choco install gh 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 Paste the token you created on GitHub and press Enter.
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://yourusername#github.com': //Then enter generated token
Generating a GitHub personal access token (PAT) Log in to your GitHub account and open Settings → Developer Settings Personal Access Tokens. Click on Generate New Token. Do not forget to copy and the token after generation. It is accessible only once. Windows Open Control Panel → User Accounts → Credential Manager. Now, look for git:https://github.com. Click on Edit. Replace the password with the GitHub Personal Access Token. MAC Click on Spotlight Icon and search for Keychain Access. Inside Keychain Access, search for github.com. Now, look for the internet password entry for github.com. Update the entry.
Go to Settings → Developer settings → generate a new token if it does not exist. Or copy the token if it exists. Then set the token: git remote set-url origin https://<token>#github.com/<username>/<repo>.git/
Mac users -- a simple solution. Set up the personal access token in GitHub: Settings → Developer Settings → Personal 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.
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.
You can force your machine to just use SSH instead of HTTPS: git config --global url."git#github.com:".insteadOf "https://github.com/"
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
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 #.
A quick solution for Windows users Open Credential Manager and just remove the already-saved credentials for Git: https://github.com. 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). After successful login, we got this message: For more help related to this, you can also watch this video.
The best solution I have found so far: Install GitHub CLI, brew install gh or check how to install for other OSes Type gh auth login in your terminal 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
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.
Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. Solution 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 :-)
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.
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
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
First you need SSH Key Based Authentication Windows Tutorial: SSH Key Authentication Linux/Mac Tutorial: SSH Key-Based Authentication Documentation And then Generate a personal token Set your user name: git config --global user.name "userName" Set your email address: 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
If you want to clone for the first time: git clone https://<repository_owner>:<personal_access_token>#github.com/<repository_owner>/<repo>.git
github personal access token issues
I am trying to set up and use a GitHub personal access token. I have followed https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token and have created the token. I have looked at https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#switching-remote-urls-from-ssh-to-https and I can https URLs returned when I run git remote -v When I try and push I get a GitHub login prompt. I close that and get an OpenSSH prompt. I close that and type in my username and get another OpenSSH prompt for my password. I close that and put in my personal access token and that still doesn't work. According to the first link I should just be prompted for a username and token. Is there something else I need to do? I'm on Windows. When I try on Linux (Ubuntu) I just a username and password prompt and the token works.
If you are on Windows (with the latest Git For Windows), and do see an HTTPS URL on git remote -v, then the prompt should not be an OpenSSH one. Make sure your git config credential.helper is set to manager-core. Then a git push should ask for your credentials, where you can use your token as password. Or: the OP tschumann makes it work by removing the credential helper. To make sure there is no credentials cached though, I prefer: checking that C:\Program Files\Git\mingw64\libexec\git-core is in my %PATH% double-check what is stored in the Windows Credential Manager That is: printf "host=github.com\nprotocol=https"|git-credential-manager get If you see the wrong password, remove it with printf "host=github.com\nprotocol=https"|git-credential-manager erase Repeat the erase command until you see a popup (do not enter your credentials) Then do a git push, and enter your credentials to store them. The OP tschumann confirms in the comments: git config --global core.askPass "" ended up fixing the issue
Creating ssh key in github
I have a question regarding managing two Github accounts in my machine (office and personal). Whenever I create a repo in personal am I supposed to create a new ssh key(As my office git account username and email are global)? Using windows credentials way I'm prompted to enter the username and password for the first time I do remote push then onwards I need not have to do that for that particular repo. I wanted to try by ssh(to avoid entering my git account credentials for the first time) or can I stick with the windows credential manager way?
Whenever I create a repo in personal am I supposed to create a new ssh key(As my office git account username and email are global)? No: the SSH key remains the same and is used to authenticate you to your personal GitHub account. You only need to register that key in your ~/.ssh/config file: Host perso Hostname github.com User git IdentityFile ~/.ssh/myPersoKey Then, in your local cloned repository: cd /path/to/local/clone git remote set-url origin perso:<me>/<myrepo> Then a git push will use the SSH URL, with the right perso key.
Can't push to git
Once I had an old github account, and I'm trying to create a new one and push to that one, but I keep running into permission issues: remote: Permission to <new account>/<new account>.github.io.git denied to <old username>. I've tried setting the user name + password, going through different procedures to add ssh keys, deleting my .ssh folder, deleting my old repos, everything I can think of, but I can't fix this.
Check first if your URL is actually an SSH one: git remote -v If it is an https,... no amount of SSH setting will allow you to authenticate properly. If it is an https (again), do check your credential helper with: git config credential.helper If you see manager, it is possible the wrong credentials are cached. In that case, you need to remove them. See "Github remote permission denied". The other possibility is the presence of 2FA (2 factor Authentication), which would require a PTA (Personnal Access Token) in place of the regular account password. But again, you can also switch to an SSH URL: git remote set-url origin git#github.com:auser/arepo.git
GitHub: invalid username or password
I have a project hosted on GitHub. I fail when trying to push my modifications on the master. I always get the following error message Password for 'https://git#github.com': remote: Invalid username or password. fatal: Authentication failed for 'https://git#github.com/eurydyce/MDANSE.git/' However, setting my ssh key to github seems ok. Indeed, when I do a ssh -T git#github.com I get Hi eurydyce! You've successfully authenticated, but GitHub does not provide shell access. Which seems to indicate that everything is OK from that side (eurydyce being my github username). I strictly followed the instructions given on github and the recommendations of many stack discussion but no way. Would you have any idea of what I may have done wrong?
After enabling Two Factor Authentication (2FA), you may see something like this when attempting to use git clone, git fetch, git pull or git push: $ git push origin master Username for 'https://github.com': your_user_name Password for 'https://your_user_name#github.com': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/your_user_name/repo_name.git/' Why this is happening From the GitHub Help documentation: After 2FA is enabled you will need to enter a personal access token instead of a 2FA code and your GitHub password. ... For example, when you access a repository using Git on the command line using commands like git clone, git fetch, git pull or git push with HTTPS URLs, you must provide your GitHub username and your personal access token when prompted for a username and password. The command line prompt won't specify that you should enter your personal access token when it asks for your password. How to fix it Generate a Personal Access Token. (Detailed guide on Creating a personal access token for the command line.) Copy the Personal Access Token. Re-attempt the command you were trying and use Personal Access Token in the place of your password. Related question: https://stackoverflow.com/a/21374369/101662
https://git#github.com/eurydyce/MDANSE.git is not an ssh url, it is an https one (which would require your GitHub account name, instead of 'git'). Try to use ssh://git#github.com:eurydyce/MDANSE.git or just git#github.com:eurydyce/MDANSE.git git remote set-url origin git#github.com:eurydyce/MDANSE.git The OP Pellegrini Eric adds: That's what I did in my ~/.gitconfig file that contains currently the following entries [remote "origin"] url=git#github.com:eurydyce/MDANSE.git This should not be in your global config (the one in ~/). You could check git config -l in your repo: that url should be declared in the local config: <yourrepo>/.git/config. So make sure you are in the repo path when doing the git remote set-url command. As noted in Oliver's answer, an HTTPS URL would not use username/password if two-factor authentication (2FA) is activated. In that case, the password should be a PAT (personal access token) as seen in "Using a token on the command line". That applies only for HTTPS URLS, SSH is not affected by this limitation.
Solution steps for Windows users: Control Panel Credential Manager Click Windows Credentials In Generic Credential section ,there would be git url, update username and password Restart Git Bash and try for clone Note: If you didn't find git url in Generic Credential section then follow below answer https://stackoverflow.com/a/55858690/7372432
If like me you just updated your password and ran git push to run into this issue, then there's a super easy fix. For Mac users only. You need to delete your OSX Keychain access entries for GitHub. You can do it via terminal by running the following commands. Deleting your credentials via the command line Through the command line, you can use the credential helper directly to erase the keychain entry. To do this, type the following command: git credential-osxkeychain erase host=github.com protocol=https # [Now Press Return] If it's successful, nothing will print out. To test that it works, try and clone a repository from GitHub or run your previous action again like in my case git push. If you are prompted for a password, the keychain entry was deleted.
When using the https:// URL to connect to your remote repository, then Git will not use SSH as authentication but will instead try a basic authentication over HTTPS. Usually, you would just use the URL without a username, e.g. https://github.com/username/repository.git, and Git would then prompt you to enter both a username (your GitHub username) and your password. If you use https://something#github.com/username/repository.git, then you have preset the username Git will use for authentication: something. Since you used https://git#github.com, Git will try to log in using the git username for which your password of course doesn’t work. So you will have to use your username instead. The alternative is actually to use SSH for authentication. That way you will avoid having to type your password all the time; and since it already seems to work, that’s what you should be using. To do that, you need to change your remote URL though, so Git knows that it needs to connect via SSH. The format is then this: git#github.com:username/repository. To update your URL use this command: git remote set-url origin git#github.com:username/repository
Instead of git pull also try git pull origin master I changed password, and the first command gave error: $ git pull remote: Invalid username or password. fatal: Authentication failed for ... After git pull origin master, it asked for password and seemed to update itself
2FA is enabled and getting error remote: Invalid username or password. fatal: Authentication failed for If you set 2FA is enabled in GitHub you will need to enter a personal access token instead of a 2FA code and your GitHub password. How to fix it https://github.com/settings/tokens generated token Copy the Personal Access Token Now enter Personal Access Token in the place of your password during git operation
just try to push it to your branch again. This will ask your username and password again, so you can feed in the changed password. So that your new password will be stored again in the cache.
This is the answer. Set the github token: https://github.com/settings/tokens And then: git remote set-url origin https://[token]#github.com/your_repository
I am getting this while cloning app from bitbucket: Cloning into 'YourAppName'... Password for 'https://youruser id': remote: Invalid username or password I solved it. Here you need to create password for your userid Click on Your profile and settings Then Create app password choose your name password will generated ,paste that password to terminal
That problem happens sometimes due to wrong password. Please check if you are linked with AD password (Active Directory Password) and you recently changed you AD password but still trying git command with old password or not. Update old AD password Control Panel > Credential Manager > Windows Credential > change github password with my new AD password
I have got the success using the following commands. git config --unset-all credential.helper git config --global --unset-all credential.helper git config --system --unset-all credential.helper Try and let me know if these are working for you.
No need to rely on Generating a Personal Access Token and then trying and use Personal Access Token in the place of your password. Quick fix is to set your remote URL to point to ssh not https. Do this git remote set-url origin git#github.com:username/repository
I did: $git pull origin master Then it asked for the [Username] & [Password] and it seems to be working fine now.
If you have just enabled 2FA : Modify hidden config file in ./git hidden folder as follow : [remote "origin"] url = https://username:PUT_YOUR_2FA_TOKEN_HERE#github.com/project/project.git
Try this: # git remote set-url origin git#github.com:username/repository
Run Below command, and after than on every push and pull it will ask you to enter the username and password. git config credential.helper "" now when you pull/push you will be asked for git credentials. weather you are running through command prompt or Intellij Git.
Disabling 2 factor authentication at github worked for me. I see that there is a deleted answer that says this, with the deletion reason as "does not answer the question". If it works, then I think it answers the question...
You might be getting this error because you have updated your password. So on Terminal first make sure you clear your GitHub credentials from the keychain and then push your changes to your repo, terminal will ask for your username and password.
In case you get this error message in this situation: using github for entreprise using credential.helper=wincred in git config using your windows credentials which you changed recently Then look at this answer: https://stackoverflow.com/a/39608906/521257 Windows stores credentials in a credentials manager, clear it or update it.
Control panel Credential manager Look for options webcredentials and windows credentials in either one you will find github credentials fix it with correct credentials open new instance of git bash you should be able to perform your git commands. This worked for me, I was able to pull and push into my remote repo.
I had the same issue. And I solved it by changing the remote branch's path from https://github.com/YourName/RepoName to git#github.com:YourName/RepoName.git in the repo's settings of the client app.
I'm constantly running into this problem. Make sure you set git --config user.name "" and not your real name, which I've done a few times..
I just disable the Two-factor authentication and try again. It works for me.
Since you probably want to keep 2FA enabled for your account, you can set up a ssh key and that way you won't need to type your Github credentials every time you want to push work to Github. You can find all the ssh setup steps in the documentation. First, make sure you don't currently have any ssh keys (id_rsa.pub, etc.) with $ ls -al ~/.ssh
I fixed my issue by installing GitHub CLI and running gh auth login See: https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git#github-cli
I had the same issue $ git clone https://github.com/sample-url.git Cloning into 'Project'... remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/sample-url.git/' I just git init first and then git clone <clone-url> git init git clone https://github.com/your-clone-Url It worked for me.
There is a issue on Windows using cmd-Greetings There is a issue on Windows using cmd-Greetings who will not let you clone private repositories. Remove that cmd-greeting described in this documentation (keyword Command Processor): Known-Issues I can confirm that other clients like SourceTree, GitKraken, Tower and TortoiseGit affected to this issue too.
There are many reasons why this might happen. In my case, none of the solutions worked. In particular, git pull origin master did not ask me for my username and password. I was on Windows with a github password recently changed. I was using the credential manager to manage my password. Here is what worked for me: Confirm you are using the credential manager for git: git config --list … credential.helper=manager Run a new command prompt as administrator List all stored credential with cmdkey /list from C:\WINDOWS\system32> Remove the github target with cmdkey /delete:<target name>. In my case, the target name was github.<companyname>.com Open a new prompt and run a git command. You should get a popup asking for your usernmame and password. After providing the new credentials, it won't ask you for it again.
When I faced this issue all I did to resolve it was to Generate new token from my github dashboard and paste the following code in my terminal $ git remote set-url origin https://your-github-username:your-github-token#github.com/your-github-username/your-github-repo.git