Visual Studio 2017 年团队基础错误 git bash "failed to acquire credentials"

Visual Studio 2017 Team Foundation Error git bash "failed to acquire credentials"

环境:

当 "Team Explorer -> Sync"

时出现 Team Foundation 错误

输出(源代码管理 - Git)显示

Opening repositories:
C:\Users\user\Documents\Projects\project
Git failed with a fatal error.
failed to acquire credentials.
failed to acquire credentials.
failed to acquire credentials.
From ssh://developer.whereprojectis.com/projects/project
 = [up to date]      master     -> origin/master
 * [new branch]      Version1.5 -> origin/Version1.5
 * [new branch]      gov        -> origin/gov
 * [new branch]      ver1.6.0   -> origin/ver1.6.0

remote origin ssh://git@developer.whereprojectis.com/projects/project.git

我可以通过 git CMD 和密码获取、推送、拉取。

但是,Visual Studio 无法同步、获取、推送、拉取。

我该如何解决这个问题?


我也无法通过 Source Tree 推拉。

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
Error reading SSH_ASKPASS output for prompt: Password:
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I can fetch, push, pull by git CMD with password.

这意味着您的 SSH 私钥有密码。
注意:您可以考虑使用一个 without 密码来避免 ssh 代理设置。

关于 SourceTree,检查 git 它在设置中使用的是什么(本机或系统):尝试系统一。
并检查 Tools > Options > General > SSH Client Configuration:它应该使用 OpenSSH。

在我的例子中,答案相当简单:visual studio 从来没有问过我密码,因为 ssh 客户端还不知道服务器的 hostkey/fingerprint。 在这种情况下,当您 push/pull 第一次通过 ssh 时,您会收到相应的消息并提示您是否要接受密钥。 不幸的是,VisualStudio 2019 并不关心它然后卡住了,因为 git 由于不接受 servert 主机密钥而取消了请求。

在命令提示符下 git 服务器上的第一个 repo 上首先拉取并手动接受那里的密钥为我解决了这个问题。从那以后工作正常。