Git 身份验证仅在 Bower 安装期间失败(退出代码 #128)

Git authentication fails during Bower install only (exit code #128)

我正在构建一个将 Git 存储库作为依赖项的项目:

"dependencies": {
    "base-resources": "git@git.companyname.com:bower-projects/base-resources.git"
}

构建失败如下:

bower ECMDERR Failed to execute "git ls-remote --tags --heads git@git.companyname.com:bower-projects/base-resources.git", exit code of #128 Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,password). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

Additional error details: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

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

但是,我可以 运行 来自 Git bash 的相同命令没有问题:

git ls-remote --tags --heads git@git.companyname.com:bower-projects/base-resources.git

我已经尝试了所有常见的解决方案,such as changing the Git URL protocol,清除 Bower 缓存,并为此主机设置特定的本地 SSH 配置选项:

Host git.companyname.com
RSAAuthentication yes
IdentitiesOnly yes
IdentityFile ~/.ssh/gitlab_rsa
User git

我还应该检查哪些其他问题?

我的解决方案最终是使用 Git bash 而不是 Windows 终端(在我的例子中是 ConEmu)。两个系统之间对 SSH 密钥的处理有所不同。

  1. 运行 bower install 在 git bash
  2. 清理C:\Users\AppData\Local\bower
  3. 下的bower目录
  4. 运行 git config --global url.https://.insteadOf git://
  5. 然后bower cache clean
  6. 终于又bower install了。

我可以通过启动命令行 运行 安装 bower 包 window "as Administrator".