VSTS(Azure Devops)的ssh -T成功认证,但git clone失败 [英] `ssh -T` to VSTS(Azure Devops) authenticates successfully, but `git clone` fails

查看:74
本文介绍了VSTS(Azure Devops)的ssh -T成功认证,但git clone失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I recently created a second key to access Visual Studio Team Services,

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

所以我现在有两个键:

id_github
id_vsts

这两个键似乎都已被ssh拾取:ssh-add -l列出了这两个键.

Both keys seem to have been picked up by ssh: ssh-add -l lists both of them.

接下来,我在帐户安全性中添加了id_vsts.pub.正确添加了密钥,因为请求SSH终端访问已正确认证:

Next, I added id_vsts.pub to my VSTS account security. The key was properly added because requesting SSH terminal access authenticates properly:

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

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

However, when I git clone ssh://[user]@[host]:22/[repo], it fails!

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

在意外情况下,如果我使用id_github的公钥,则克隆成功.发生了什么事?

In an unexpected turn of events, if I use id_github's public key, the clone succeeds. What's going on?

推荐答案

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

You need to force the client to use specific private key, otherwise it uses the default one.

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

To check which private key file used for a host, you can run

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

一种方法是您可以在配置文件中对其进行配置. (我的Windows步骤)

One way is that you can configure it in the config file. (My steps for windows)

  1. 如果.ssh文件夹中没有配置文件,请运行touch .ssh/config
  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命令.

Another way is that, you can run ssh -i /path/to/id_rsa user@server.nixcraft.com command.

更多信息,您可以参考本文:

More information, you can refer to this article: Force SSH Client To Use Given Private Key (identity file)

这篇关于VSTS(Azure Devops)的ssh -T成功认证,但git clone失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆