通过 SSH 从 VSTS 克隆 Git 存储库需要密码!意外 [英] Cloning a Git repo from VSTS over SSH asks a password! Unexpected

查看:27
本文介绍了通过 SSH 从 VSTS 克隆 Git 存储库需要密码!意外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标是在不提供任何密码的情况下克隆 Visual Studio Team Services 中的 Git 存储库.进一步的目标是完全非交互式地完成,完全没有任何提示.

The goal is to clone a Git repository in Visual Studio Team Services without providing any passwords. The further goal is to do it completely non-interactively, without any prompts at all.

问题描述:

操作系统是Windows Server 2016.假设我的用户名是batman.我已经在 Windows 中的 C:Usersatman.sshid_rsa 中设置了私钥(没有密码).

Operating system is Windows Server 2016. Let's say my user name is batman. I have set up the private key (without passphrase) in Windows at C:Usersatman.sshid_rsa.

我已在 VSTS 上为我的用户帐户添加了公钥.一切都很好.

I have added the public key for my user account at VSTS. All good.

我想克隆存储库,而 VSTS Web UI 为我提供了一个存储库的 SSH URL.我在我执行的以下命令中使用它:

I want to clone the repository and VSTS web UI provides me an SSH URL to the repository. I use it in the following command that I execute:

git clone ssh://mycompany@mycompany.visualstudio.com:22/MyProject/_git/MyRepo

回复:

Cloning into 'MyRepo'...
Enter passphrase for key '/c/Users/batman/.ssh/id_rsa':
mycompany@mycompany.visualstudio.com's password:

因此,首先它会询问我只需按 Enter 键的密钥密码,但最后一行令人困惑.我应该输入什么密码,为什么要问它?怎么让它不问呢?如何让clone命令根本不问什么?

So first it asks for the key passphrase where I just press Enter but the last line is confusing. What password should I input and why is it asking it? How to make it not ask it? How to make the clone command not ask anything at all?

推荐答案

首先,它会询问您的私钥的密码:

First, it asks for the passphrase to your private key:

Enter passphrase for key '/c/Users/batman/.ssh/id_rsa':

从您的评论(在现已删除的答案中)我了解到您使用 PuTTy 生成密钥,我怀疑您的密钥格式不正确(也许这会有所帮助?)(或者这个?),确保它以以下开头:

From your comments (in the now deleted answer) I understood that you had used PuTTy to generate the key, and I'm suspecting that your key is not in the correct format (maybe this will help?)(or this?), make sure that it begins with:

-----BEGIN RSA PRIVATE KEY-----

并以

-----END RSA PRIVATE KEY-----

无论如何,公钥认证失败了,所以它会要求mycompany帐户的密码:

Anyway, the public key authentication fails, so it then asks for mycompany account's password:

mycompany@mycompany.visualstudio.com's password:

如果公钥认证成功就不会发生这种情况.

This would not happen if the public key authentication succeeded.

这篇关于通过 SSH 从 VSTS 克隆 Git 存储库需要密码!意外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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