Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using SourceTree For Windows With SSH Keys

Aahan Krish
Contributor
March 19, 2013

I'm using SourceTree, the stable release launched yesterday, on my Windows 7 laptop.

I generated the SSH keys using the Putty Key Generator in SourceTree, and saved them to my disk using the "Save public key" and "Save private key" options, as shown below:

Then I closed the window, and tried to import the private *.ppk key from Tools > Launch SSH Agent (Pageant) and selecting the private file. That's where the problem is. It doesn't accept the private key file:

That's the error I get. I am not sure why it's unable to open the private key file. Any idea as to what I could be doing wrong here?

5 answers

1 accepted

5 votes
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2013

Edit: Turns out the problem was saving the ppk in a path which had a space in it, and SourceTree wasn't coping with that properly when launching Pageant. This will be fixed in 0.9.0.2.

Old answer: That looks like entirely the correct process to me. I just repeated this process here and the .ppk I saved loaded back just fine. Are you sure you saved the *private* key as the .ppk? I usually call my public keys '.pub' to differentiate them from the .ppk files, the public keys are just plain text.

Aahan Krish
Contributor
March 19, 2013

Yes. The private file was saved with a .ppk extension. I don't think it'll work, but I'll reinstall sourcetree and see.

Aahan Krish
Contributor
March 19, 2013

Okay, I've tried reinstalling SourceTree to no avail. But I've found a temporary fix, which I've added as an answer. Please take a look. Does that say something? I've no idea why this is happening, or how to fix it. Hope you can find something. Looks like I should stick to github for windows for now.

Like BeibarysSabit likes this
Aahan Krish
Contributor
March 19, 2013

Steve, please edit your answer and add the comment to posted under my answer so that I can mark this as the answer. Thanks!

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2013

Updated! :)

Alan So
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 21, 2013

I have tried to load the key from my previously generated ppk file under TortoiseGit's putty keygen. I notice that SourceTree's Pageant cannot locate the ppk file if it is saved to TortoiseGit's directory in C:\"Program Files" or directly under C:\. Well, the file is actually unable to be located using "Computer" or command line (run as myself or administrator). But it is ok if I save the key under my Documents directory.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 21, 2013

This might be because you need administrator permissions to do access these locations. SourceTree runs as your own user and not as administrator like TortoiseGit.

11 votes
Aahan Krish
Contributor
March 19, 2013

UPDATE: Apparently it's a bug. See Steve Streeting's answer.

I'd consider the error a bug, but what do I know. Anyway, I finally got it to work, and here are my findings.

Undo what you did:

  • Go to SourceTree > Tools > Options > General (Tab) > SSH Key, clear the field, and hit 'OK'.

The workaround:

  1. Go to SourceTree > Tools > Create or Import SSH Keys (that should open the 'Putty Key Generator' dialog), hit 'Generate' button to generate a new set of private and public SSH keys, and save them as shown in my question. Then close the 'Putty Key Generator' dialog box.
  2. Go to SourceTree > Tools > Launch SSH Agent (Pageant) — this is where the bug is — when the 'Select an SSH key file to load (PuTTY format)' dialog box appears, DON'T select your .ppk file. Simply hit 'Cancel'.
  3. No worries, as you'll notice that Pageant (PuTTY authentication agent) is still running in the system tray!


  4. Right-click on Pageant icon (in the system tray) > Add Key and select the private key file (.ppk) this time.
  5. Now you can carry on with the rest of the process. But the problem is, you'll have to repeat this everytime you launch SourceTree. At least until Atlassian fixes what appears to be a bug to me.
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2013

I couldn't reproduce this at all, until I tried placing the ppk in a folder which had a space in it. This is the root of the problem, which will be fixed in the next update.

Vinayan Pushpa
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 16, 2016

I have been chasing to solve this similar issue with my source tree , I tried all these steps which were provided.. but no luck sad

Like # people like this
Tom Miller March 16, 2016

This is still a bug in Version 1.8.2.11

jheller57
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 3, 2016

After MUCH stuffing around, I finally got Sourcetree on Windows to work. I'm using version 1.8.3.0.

It would just hang when I put in an SSH URL while trying to verify if it was a git repo. The problem was that putty had not accepted the remote host key.

The fix: try logging into the remote host using putty itself. The log-in will probably fail (depending on how SSH is set up on the remote server), but you will get the opportunity to save the host key.

Thereafter SourceTree will actually work with the SSH URL.

Tim Brown
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 14, 2016

I'm using version 1.8.3.0
Only way I was able to get around this:

  • Quit Sourcetree
  • Exit pageant from system tray
  • Then restart pageant.
  • Add Key to pageant
  • Restart Sourcetree

Somehow sourcetree wasn't able to read the keys loaded in the agent.

Like Anna Mora likes this
Tom Miller April 15, 2016

This bug seems to be 2 fold.  One is the "space" in the directory structure.  The second is it doesn't really "save" the decryption of the local key.  I have to type it in every time I restart my computer and possibly SourceTree itself.  

Gumml April 18, 2016

It doesn't work at all on my machine. Got a fresh installation of SourceTree and I'm not able to clone a repository from Bitbucket at all. Don't even get an error message in the GUI. If I start the git bash (not by pressing Terminal as it doesn't work as long as you don't have a local repository, but from the containing folder) it's reporting an authentication error. Really need my SourceTree but can't fix it somehow

DT
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 12, 2016

Nice! This worked out for me! Thank you!

darrensapalo
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 25, 2017

This (set of instructions under the heading 'The workaround') worked for me too.

Edy B June 27, 2018

Using version 2.6.9.0 and still having the same issue.

Roger Guess
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 17, 2019

Still a constant PITA and now I cannot get it working on any repository.

Josh Noe
Contributor
July 6, 2019

I gave up. I just use the console to push. I guess it's time to switch to a different git app.

Like # people like this
Gumml July 6, 2019

unfortunately, there's no real alternative. GitKraken looks fine, but on my linux system it only works properly when I work alone in a repository. If other users commit, GitKraken is somehow not able to pull anymore because it displays a merge conflict which isn't existing. Then I have to use the console to do the pull (which works just fine) and then it's working again. The GitKraken devs take care of their programme just as Atlassian...

Josh Noe
Contributor
July 7, 2019

@Gumml SmartGit isn't too bad once you change it's quirky defaults and if you can tolerate light mode (it's dark mode is pretty bad). Agreed that GitKraken is pretty flaky, it also doesn't support stashing individual files.

8 votes
nuru
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 18, 2018

5 years have passed and this is still a problem, come on atlassian, could have written my own client in this time

2 votes
Camilo Rojas Díaz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 4, 2019

For me "Launch SSH Agent" does nothing. I can import my converted SSH key in the "create or import SSH keys" but after closing the dialog it doesn't stay loaded.

1 vote
Hà Ngọc Thái
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 3, 2019

1. Launch SourceTree -> Tools -> Create or Import SSH Keys
2. Launch SSH Agent (Pageant) and add the private file
3. Go to bitbucket -> choose your repository -> Settings -> Access keys -> Add key

Markus Miller July 3, 2019

It works in the standard version of source tree just fine. It's a problem of the enterprise version. You can choose between having a working SSH key connection or a different application path. Fucked up...

Like vahram_p likes this
Josh Noe
Contributor
July 6, 2019

Doesn't work if your ssh key is password protected.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events