`sss -t` to vSTS(azure devops)成功身份验证,但是``git clone''失败了



我最近创建了第二个键来访问Visual Studio Team Services,

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

所以我现在有两个密钥:

id_github
id_vsts

两个键似乎已经被SSH拾取:ssh-add -l列出了这两个键。

接下来,我将id_vsts.pub添加到我的VSTS帐户安全性。正确添加了密钥,因为请求SSH终端访问正确身份验证:

Authentication for user with identifier "" was successful against account "my_account". 
Shell is not supported.

但是,当我 git clone ssh://[user]@[host]:22/[repo]时,它会失败!

Your Git command did not succeed.
Details:
        Public key authentication failed.

在意外的事件中,如果我使用id_github的公钥,则克隆成功。发生了什么事?

在我的情况下,将 IdentitiesOnly yes添加到vso主机的~/.ssh/config文件中。

您需要强迫客户端使用特定的私钥,否则它使用默认的键。

要检查用于主机的哪个私钥文件,您可以运行

ssh -v [host(e.g. test@test.visualstudio.com)]

一种方法是您可以在配置文件中配置它。(我的Windows步骤)

  1. 运行touch .ssh/config如果.SSH文件夹中没有配置文件
  2. 打开配置文件

代码:

Host xx.visualstudio.com
  IdentityFile /c/Users/xx/.ssh/id_vsts
  1. 打开新命令行并运行Git clone命令

另一种方法是,您可以运行ssh -i /path/to/id_rsa user@server.nixcraft.com命令。

更多信息,您可以参考本文:强制SSH客户端使用给定的私钥(身份文件)

显然Git仅使用提供的第一个密钥,如果失败,Git Clone会失败。我的SSH配置具有通配符选项,并在GIT键之前具有键匹配,因此它不起作用。将git配置移至.sss/config的顶部都很好。

相关内容

最新更新