windows git clone:<URL> 的身份验证失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51424051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:04:48  来源:igfitidea点击:

git clone: Authentication failed for <URL>

windowsgittfscredentials

提问by SLCH000

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

尝试访问私人公司 tfs。他们通过为 Windows 用户(域\登录)提供适当的权限来给我访问权限。

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

我可以访问 tfs 的 Web 界面、浏览存储库和其他东西。

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.

在 PowerShell、Git Bash、通过 VisualStudio 克隆中尝试过 - 同样的错误。

SSH is closed (gave request timeout).

SSH 已关闭(请求超时)。

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

Web 和 Git 都要求提供一次凭据(尝试在凭据管理器中删除 - 再次询问,提交 Web 后,git 失败)

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

公司帮手试图提供帮助,但他提供的只是 tfs 日志。他说,我的用户名没有附带请求(通过将我的尝试时间戳与日志同步来跟踪)。

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

采纳答案by SLCH000

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.

如果有人查看了此线程,但它不是适合您的解决方案 - 请查看我在问题中描述的问题和步骤下的评论,它们可能对您有用。

回答by RBT

I'm facing exactly same error when I'm trying to clone a repository on a brand new machine. I'm using Git bash as my Git client. When I ran Git's command to clone a repository it was notprompting me for user id and password which will be used for authentication. It was a fresh machine where not a single credential was cached by Windows credential manager.

当我尝试在全新机器上克隆存储库时,我面临完全相同的错误。我使用 Git bash 作为我的 Git 客户端。当我运行 Git 的命令来克隆存储库时,它没有提示我输入将用于身份验证的用户 ID 和密码。这是一台全新的机器,Windows 凭据管理器没有缓存任何凭据。

As a last resort, I manually added my credentials in credentials manager.

作为最后的手段,我在凭据管理器中手动添加了我的凭据。

Go to > Control Panel\User Accounts\Credential Manager> Windows Credentials

前往 > Control Panel\User Accounts\Credential Manager>Windows Credentials

Click Add a Windows credentiallink and then Supply the details as shown in the form below and you're done:

单击Add a Windows credential链接,然后提供如下表格所示的详细信息,您就完成了:

enter image description here

在此处输入图片说明

I had put the details as below:

我已经把细节如下:

Internet or network address: 192.168.1.100
User Name: MyCompanysDomainName\MyUserName
Password: MyPassword

Next time this manually cached credential will be used whenever you run any Git command targeting a repository set up on above address(192.168.1.100).

下次无论何时运行任何针对在上述地址 (192.168.1.100) 上设置的存储库的 Git 命令时,都会使用此手动缓存的凭据。

Sharing my experience here in case it helps someone in future.

在这里分享我的经验,以防将来对某人有所帮助。

回答by Elwont

Adding usernameand passwordhas worked for me: For e.g.

添加usernamepassword对我来说有效:例如

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

回答by Martin Staufcik

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

如果有人在使用 Azure DevOps 时遇到此问题,修复方法非常简单,只需将 Git 凭据添加到存储库即可。

enter image description here

在此处输入图片说明

回答by Kiran Modini

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!

通过 Bash/VS Code 使用“fatal:Authentication failed”克隆存储库时,我遇到了同样的问题。我使用 SSH 密钥身份验证代替以下文章连接我的存储库:[ https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure -devops&tabs=current-page][1]使用任何 bash 命令后我都没有收到任何错误!

回答by TreeAndLeaf

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

回答by unobatbayar

Anyone who is experiencing similar problem, the problem is your credential is incorrect.

任何遇到类似问题的人,问题是您的凭据不正确。

Go to > Control Panel\User Accounts\Credential Manager> Windows Credentialsand remove all generic credentials involving git. This way you're resetting all the credentials; After this, when you try to clone and it will ask your username and password instead of Authentication error, which then will work.

转到 > Control Panel\User Accounts\Credential Manager>Windows Credentials并删除所有涉及 git 的通用凭据。这样您就可以重置所有凭据;在此之后,当您尝试克隆时,它会询问您的用户名和密码而不是身份验证错误,然后就会起作用。