git clone: Authentication failed for <URL>

WindowsGitTfsCredentials

Windows Problem Overview


Trying to access private corporate tfs. They gave me access by giving appropriate rights to windows user (domain\login).

I'm fine with accessing web interface of tfs, browse repository and stuff.

But when I try to run

 git clone https://tfs.somehostname.com/tfs/somefolder/_git/therepository

It fails with

Cloning into 'therepository'...

fatal: Authentication failed for 'https://tfs.somehostname.com/tfs/somefolder/_git/therepository/'

Tried with home pc without corporate network stuff - same error.

Tried in PowerShell, Git Bash, Clone via VisualStudio - same error.

SSH is closed (gave request timeout).

Web & Git both ask for credentials once (tried deleting in Credentials Manager - asks again, after submitting web is fine, git fails)

Corporate helper tried to help, but all he gave is tfs logs. He says, my username doesn't come with requests (tracked by syncing my attempts timestamps with logs).

2018-07-19 07:04:00 SOMEIP GET /tfs/SOMEFOLDER/_git/REPOSITORY/info/refs service=git-upload-pack 443 - ANOTHERIP git/2.12.2+(Microsoft+Windows+NT+6.3.9600.0;+Win32NT+x64)+CLR/4.0.30319+VS15/15.0.0 - 401 2 5 62
2018-07-19 07:23:00 SOMEIP GET /tfs/SOMEFOLDER/_git/REPOSITORY/info/refs service=git-upload-pack 443 - ANOTHERIP git/2.18.0.windows.1 - 401 2 5 62
2018-07-19 07:23:00 SOMEIP GET /tfs/SOMEFOLDER/_git/REPOSITORY/info/refs service=git-upload-pack 443 - ANOTHERIP git/2.18.0.windows.1 - 401 1 3221225581 187

while others include it

2018-07-19 05:44:27 SOMEIP GET /tfs/SOMEFOLDER/_git/REPOSITORY/info/refs service=git-upload-pack 443 DOMAIN\LOGIN ANOTHERIP git/2.12.2+(Microsoft+Windows+NT+6.1.7601+Service+Pack+1;+Win32NT+x64)+CLR/4.0.30319+VS15/15.0.0 - 200 0 0 265

Windows Solutions


Solution 1 - Windows

I faced same error on my development machine. I was trying to clone a repository. My machine had a newly installed Windows Server operating system. I was using Git bash as my Git client. When I ran Git's command to clone a repository it was not prompting me for user id and password which will be used for authentication. It was a new PC so no credentials were cached by Windows credential manager.

As a last resort, I manually added my credentials in credentials manager following below steps:

  1. Press Window + R to open Run prompt.
  2. Type Control and press OK
  3. Click User Accounts on Control Panel window.
  4. Click Credential Manager on User Accounts window.
  5. Click Windows Credentials on Credential Manager window.

Now, click Add a Windows credential in Windows Credentials section as shown below:

enter image description here

Now, enter the details as shown in the form below and click OK:

enter image description here

I had put the details as below:

Internet or network address: <gitRepoServerNameOrIPAddress>
User Name: <DomainName\MyUserName>
Password: <MyPassword>

Next time when you run any Git command targeting a repository set up on above address, this manually cached credential will be used.

Note:

  1. Close and relaunch any open Git bash, Powershell or command shell for the credential caching to take effect.
  2. From now on, whenever your domain account password changes then you'll have to update it on this screen as well. In corporate environment this happens regularly due to password rotation policy.

Solution 2 - Windows

Go to > Control Panel\User Accounts\Credential Manager > Manage Windows Credentials and remove all generic credentials involving Git. (This way you're resetting all the credentials)

After this, when you clone, you'll be newly and securely asked your Git username and password instead of Authentication error.

Hope it helps.

Solution 3 - Windows

Adding username and password has worked for me: For e.g.

https://myUserName:myPassWord@myGitRepositoryAddress/myAuthentificationName/myRepository.git

Solution 4 - Windows

For cloning a private repository simply putting the password and username will not be enough as the terminal will not tell but you will have to copy the personal_access_token using the github account and put it in the place of your password.

$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token

Further you can easily access your token through the steps given below: - Go to Settings
Developer Setting
Personal_acess_token
Now check the repo column and now click on Generate token Generate token
Congratulations!!
Now copy and it and paste it when the terminal asks for password.

NOTE: - Treat your tokens like passwords and keep them secret

Solution 5 - Windows

If credentials are not asked then simplest solution is to clone using credentials. enter image description here

Option B would be suitable in case password includes any special character which URL's treat in odd manner. This option asks password.

Solution 6 - Windows

The culprit was russian account password.

Accidentally set up it (wrong keyboard layout). Everything was working, so didnt bother changing it.

Out of despair changed it now and it worked.

If someone looked up this thread and its not a solution for you - check out comments under the question and steps i described in question, they might be useful to you.

Solution 7 - Windows

  1. Go to Control Panel\All Control Panel Items\Credential Manager and select Generic Credentials.
  2. Remove all the credential with your company domain name.
  3. Git clone repository from git bash terminal once again and it will ask for password and username. Insert it again and you are all set!

Solution 8 - Windows

In case someone is facing this issue with Azure DevOps, there the fix is very easy, just adding Git credentials to a repository.

enter image description here

Solution 9 - Windows

I had this same issue with my windows 10 machine, I tried many solutions but nor worked until I installed the latest git version. https://git-scm.com/downloads.

Solution 10 - Windows

As the other answers suggest, editing/removing credentials in the Manage Windows Credentials work and does the job. However, you need to do this each time when the password changes or credentials do not work for some work. Using ssh key has been extremely useful for me where I don't have to bother about these again once I'm done creating a ssh-key and adding them on the server repository (github/bitbucket/gitlab).

Generating a new ssh-key

  1. Open Git Bash.

  2. Paste the text below, substituting in your repo's email address. $ ssh-keygen -t rsa -b 4096 -C "[email protected]"

  3. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

  4. Then you'll be asked to type a secure passphrase. You can type a passphrase, hit enter and type the passphrase again.

Or, Hit enter twice for empty passphrase.

  1. Copy this on the clipboard:

    clip < ~/.ssh/id_rsa.pub

And then add this key into your repo's profile. For e.g, on github->setting->SSH keys -> paste the key that you coppied ad hit add

Ref: https://help.github.com/en/enterprise/2.15/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key

You're done once and for all!

Solution 11 - Windows

After trying almost everything on this thread and others, continuing to Google, the only thing that worked for me, in the end, was to start Visual Studio as my AD user via command line:

cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE
runas /netonly /user:<comp\name.surname> devenv.exe

Original issue: [1]: https://developercommunity.visualstudio.com/content/problem/304224/git-failed-with-a-fatal-errorauthentication-failed.html

My situation is I'm on a personal machine connecting to a company's internal/local devops server (not cloud-based) that uses AD authorization. I had no issue with TFS, but with git could not get the clone to work (Git failed with a fatal error. Authentication failed for [url]) until I did that.

Solution 12 - Windows

I had the same issue when Cloning the repository via Bash/VS Code with "fatal:Authentication failed". I used SSH Key authentication instead to connect my repository following the article: [https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops&tabs=current-page][1] I didn't get any errors after with any bash commands!

Solution 13 - Windows

Rather than escape my password I left it out and was prompted for it, but only when I included the domain name before my username:

git clone https://some-dom-name\[email protected]/tfs/...

Solution 14 - Windows

In my case the error was some old username and password was stored in cache.

So I removed it by going to sourceTree and delete the existing account.

Now for the new clone then it will ask you for the password for the repo. enter image description here

Solution 15 - Windows

An alternative answer here. Open git bash go to path git/mingw64/libexec/git-core and run the following command:

./git-credential-manager clear

Next time you execute a clone, a dialog will open and which credential manager do you want. I selected wincred (don't know if it is the best option). Checked the box so it won't ask again. Another similar dialog will open again.

By the way, it always better to authenticate using your ssh keys. Don't checkout using https. If you have to type your password every time you interact with the server, you will do it less, and merge your code less often. More conflicts will happen.

Solution 16 - Windows

Despite having login failed through Sorucetree and gitbash by entering credentails in the prompt window, GitHub Desktop application worked with no hassle

GitHub Desktop

Solution 17 - Windows

I have just had this issue. The easiest way is to select Clone in Visual Studio. Visual Studio then prompts for your credentials. After you enter your credentials, you set the path. Then your repository is cloned.

Solution 18 - Windows

1- Clean all the credentials from windows as stated in the answers above 2- Make sure you have the latest git, if your git is not updated to the latest version you will get this error too.

3- once you completed above steps. just simply clone and it will ask for credentials and will work

Solution 19 - Windows

For the new comers,

Upvoted answers are not the answers anymore since,

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

And no need to repeat the access token replies, go and follow them.

Solution 20 - Windows

Go to:

> Control Panel -> User Accounts -> Credential Manager -> Windows Credentials -> Generic Credentials >> Remove old credentials which were saved for the specific url

Then when you freshly clone the repository it will prompt for credentials.

Solution 21 - Windows

If you are using Gitlab, for some reason, git clone with http just does not work. Git clone with ssh is the only option.

git clone git@gitlab.example.com:demo.git

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSLCH000View Question on Stackoverflow
Solution 1 - WindowsRBTView Answer on Stackoverflow
Solution 2 - WindowsunobatbayarView Answer on Stackoverflow
Solution 3 - WindowsElwontView Answer on Stackoverflow
Solution 4 - WindowsMaheepView Answer on Stackoverflow
Solution 5 - WindowsGhanshyam BahetiView Answer on Stackoverflow
Solution 6 - WindowsSLCH000View Answer on Stackoverflow
Solution 7 - WindowsSohini RoyView Answer on Stackoverflow
Solution 8 - WindowsMartin StaufcikView Answer on Stackoverflow
Solution 9 - WindowsSamuelView Answer on Stackoverflow
Solution 10 - WindowsABGRView Answer on Stackoverflow
Solution 11 - WindowsNicole MeyerView Answer on Stackoverflow
Solution 12 - WindowsKiran ModiniView Answer on Stackoverflow
Solution 13 - WindowsTreeAndLeafView Answer on Stackoverflow
Solution 14 - WindowsAkshay Vijay JainView Answer on Stackoverflow
Solution 15 - WindowsnevesView Answer on Stackoverflow
Solution 16 - Windowstechloris_109View Answer on Stackoverflow
Solution 17 - WindowsJason AllsView Answer on Stackoverflow
Solution 18 - WindowsMJ XView Answer on Stackoverflow
Solution 19 - WindowsAyberk BaytokView Answer on Stackoverflow
Solution 20 - WindowsChathurika SenaniView Answer on Stackoverflow
Solution 21 - WindowsoohtjView Answer on Stackoverflow