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

查看:102
本文介绍了通过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 Server2016.假设我的用户名是batman. 我已经在Windows的C:\Users\batman\.ssh\id_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:\Users\batman\.ssh\id_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天全站免登陆