Cloning a Git repo from VSTS over SSH asks a passw

2019-05-15 20:11发布

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.

Problem description:

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.

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

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

The response:

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

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?

1条回答
狗以群分
2楼-- · 2019-05-15 20:59

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

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

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-----

and ends with

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

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.

查看更多
登录 后发表回答