How to Use ssh-keygen Generated SSH Key with SourceTree for Azure DevOps Repo

389 views Asked by At

I've encountered a challenge while trying to connect (clone) to my Azure DevOps repository via SourceTree.

1 - I used the PowerShell command ssh-keygen to generate an SSH key on my computer. The command generated two files in my selected folder: one for the private key that has no extension, and one for the public key with a .pub extension. The public key starts with

ssh-rsa AAAAB3NzaC1yc2EA....

, and the private key file is in the expected format, starting with

-----BEGIN OPENSSH PRIVATE KEY----- and ending with -----END OPENSSH PRIVATE KEY-----.

However, SourceTree seems to only accept Putty (.ppk) keys, and my keys generated by ssh-keygen don't meet that criteria.

I attempted to use these SSH keys with SourceTree by going to

"Tools > Import SSH Keys,"

but SourceTree did not recognize my key files. It appears that SourceTree is looking for keys in the .ppk format, which I don't have.

Is there a way to convert the SSH key from ssh-keygen to a format that SourceTree accepts, or should I generate new keys in a compatible format?

I'm seeking guidance on how to proceed so I can use SourceTree to manage my Azure DevOps repository using SSH keys.

Thank you in advance for your help!

1

There are 1 answers

0
wade zhou - MSFT On BEST ANSWER

You should change the SSH Client configuration on sourcetree from PuTTY/Plink to OpenSSH to use the keys generated from powershell.

Steps as below:

  1. Generate the keys from powershell: enter image description here

  2. On SoureTree -> Tools -> Options -> General tab, change to OpenSSH, select the isa key generated above -> click ok to save.

enter image description here

  1. open the public key file(.pub), copy the content, and input it to DevOps. enter image description here

  2. On DevOps repo, copy the SSH URL and paste to sourcetree.

enter image description here

In addition, if you encounter some connection error on sourcetree, change to use embedded git for a try.

enter image description here