ary*_*ing 6 git ssh azure-devops azure-pipelines
我最近创建了第二个访问Visual Studio Team Services的密钥,
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Run Code Online (Sandbox Code Playgroud)
所以我现在有两把钥匙:
id_github
id_vsts
Run Code Online (Sandbox Code Playgroud)
两个键似乎都被ssh选中了:ssh-add -l
列出了它们.
接下来,我添加id_vsts.pub
了我的VSTS帐户安全性.密钥已正确添加,因为请求SSH终端访问正确进行身份验证:
Authentication for user with identifier "" was successful against account "my_account".
Shell is not supported.
Run Code Online (Sandbox Code Playgroud)
但是,当我git clone ssh://[user]@[host]:22/[repo]
,它失败了!
Your Git command did not succeed.
Details:
Public key authentication failed.
Run Code Online (Sandbox Code Playgroud)
在一个意外的事件发生时,如果我使用id_github
的公钥,克隆就会成功.这是怎么回事?
您需要强制客户端使用特定的私钥,否则它将使用默认的私钥。
要检查主机使用的私钥文件,可以运行
ssh -v [host(e.g. test@test.visualstudio.com)]
Run Code Online (Sandbox Code Playgroud)
一种方法是您可以在配置文件中对其进行配置。(我的Windows步骤)
touch .ssh/config
如果.ssh文件夹中没有配置文件,请运行码:
Host xx.visualstudio.com
IdentityFile /c/Users/xx/.ssh/id_vsts
Run Code Online (Sandbox Code Playgroud)
Git clone
命令另一种方法是,您可以运行ssh -i /path/to/id_rsa user@server.nixcraft.com
命令。
有关更多信息,您可以参考本文:强制SSH客户端使用给定的私钥(身份文件)