VSTS(Azure Devops)的ssh -T成功认证,但git clone失败

预热

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

ssh-keygen -t rsa -b 4096 -C "[email protected]"

所以我现在有两个键:

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的公钥,则克隆成功。这是怎么回事?

陈星ian

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

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

ssh -v [host(e.g. [email protected])]

一种方法是您可以在配置文件中对其进行配置。(我的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 [email protected]命令。

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章