Nigel Findlater
Nigel Findlater

Reputation: 1724

Unable to use ssh to connect to visual studio online git repo

I created a key pair using

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

This created id_rsa and id_rsa.pub. I copied these into my home directory under a subdirectory .ssh. To my understanding this registers the private key and allows applications like git to use them. I then when to my visual studio online project and Added an SSH public key using the contents of id_rsa.pub. This created a Fingerprint. To my understanding this allows clients with this ssh token to access my Git repository.

Next I wanted to use this to clone my repository

$ git clone https://xyz.visualstudio.com/_git/myCode
Cloning into 'myCode'...
fatal: Authentication failed for 'https://xyz.visualstudio.com/_git/myCode/'

What do I need to do to make the git clone command use my ssh keys?

Upvotes: 1

Views: 1645

Answers (2)

starian chen-MSFT
starian chen-MSFT

Reputation: 33698

You need to use SSH endpoint: click Clone in web page > Select SSH tab

enter image description here

More information, you can refer to this article: Use SSH key authentication.

Upvotes: 1

Arount
Arount

Reputation: 10403

Since you are using https as protocol you can not enjoy the SSH advantages.

I don't know visualstudio at all, but you surely needs to change the repository's remote url from https://xyz.visualstudio.com/_git/myCode/ to something like [email protected]:/_git/myCode/

You obviously needs that the server accept your identity and needs to setup your public key somewhere in visualstudio.com (again, don't use this software, so don't know where / how)

Upvotes: 0

Related Questions