Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error message 'Authentication failed on the git remote'

I'm trying to push, pull, and whatever to my GitHub repository from Visual Studio Code.

I enter my username and password, but I'm getting the error:

Authentication failed on the git remote.

I just logged in on github.com with the same user/password. I tried creating a personal access token, using it as a password, but I got the same error.

like image 821
joakim Avatar asked Oct 10 '22 07:10

joakim


People also ask

How do I fix authentication fail in bitbucket?

Windows start up menu,Search for windows credential manager. Search for bitbucket url, Try updating password there.. and do git operation again. It should work.

How do I authenticate git GitHub?

Install GitHub CLI on macOS, Windows, or Linux. In the command line, enter gh auth login , then follow the prompts. When prompted for your preferred protocol for Git operations, select HTTPS . When asked if you would like to authenticate to Git with your GitHub credentials, enter Y .

How do I fix git always asking for credentials?

Entering Git Username and Password in Remote URL To prevent Git from asking for your username and password, you can enter the login credentials in the URL as shown. The main drawback of this method that your username and password will be saved in the command in the Shell history file.

Why am I getting authentication failed error in Git?

You may see this error when you clone a repository that is private or when you try to pull from or push to an existing repository without being correctly authenticated. There are other causes to this error. In many cases, Git does not provide specific explanations as to why authentication has failed.

Why am I getting a remote username or password error in Git?

To access private remote repositories and modify remote repositories using the Git command line, you must be authenticated. If you try to access or modify a repository and enter the wrong authentication credentials, you’ll encounter the remote: invalid username or password error. In this guide, we discuss the most common causes of this error.

Why does Git say my credentials are invalid?

In many cases, Git does not provide specific explanations as to why authentication has failed. Git often just tells you that your credentials are invalid, like this error message suggests. Let’s discuss these causes individually. We’re going to clone one of our Git repositories using SSH. The repository is called career-karma-tutorials/ck-git.

Why can't I push to my GitHub repository via HTTPS?

If you enabled two-factor authentication in your GitHub account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your GitHub account. Using this token as your password should allow you to push to your remote repository via HTTPS.


2 Answers

I believe I have found a solution to this problem. None of the solutions above worked for me. I think the root cause of this issue is that GitHub has ended support for password authentication on August 13, 2021. Instead a personal access token needs to be used.

The steps to solve this issue are as follows:

  1. Create a personal access token on GitHub.com. Tutorial here
  2. Go back to Visual Studio Code and open terminal. Type in the following command with your own user information:
git remote set-url origin https://<TOKEN>@github.com/<user_name or organization_name>/<repo_name>.git

In case you would like to follow a video guide, this one proved to be quite helpful.

like image 63
aleksejjj Avatar answered Oct 12 '22 20:10

aleksejjj


I solved it by following Caching your GitHub password in Git.

The steps are as follows:

  1. Download and install Git for Windows
  2. Run Git Bash, 'cd' to the repository directory and enter git config --global credential.helper wincred
like image 57
joakim Avatar answered Oct 12 '22 20:10

joakim