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

Sourcetree for Windows keep telling me the "server refused our key"

kyrra
Contributor
April 1, 2013

Using the latest version of Sourcetree (0.9.0.5) connecting to both GitHub and BitBucket i keep getting an error message when trying to talk to the server with Sourcetree. The error I get is:

Server refused our key
FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)

fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

I setup a PuTTY entry with the key (the .ppk containing my SSH key) and I was able to SSH successfully to bitbucket with the key, loosly following this guide. (I did this from Git Bash as well with the private key in id_rsa format and it worked too).

(will answer it myself, as it took a number of hours of playing before I got it)

5 answers

1 accepted

12 votes
Answer accepted
kyrra
Contributor
April 1, 2013

What my problem ended up being was this:

I've used PuTTY for a long time on my computer (long before Sourcetree). PuTTY saves its settings in your registry, so the settings from the "Default Settings" entry in PuTTY are loaded when Sourcetree / Pageant attempt to connect to BitBucket. Specifically my problem stemmed from a private key being set under:

Connection > SSH > Auth, in the "Private key file for authentication" box.

Once I removed that key from that box (just deleted the text), and saved the Default Settings session in PuTTY, Sourcetree started to behave properly. This was caused because Pageant will seem to only use the SSH key you have in that box, even if you have a lot of other SSH keys added to Pageant.

Debugging Tip:

How I ended up discovering this issue was using the plink tool from PuTTY. You can download it from PuTTY's site. What I ended up doing was:

  1. Downloading plink
  2. Stick it into an easily accessible directory
  3. Open a DOS cmd window (cmd.exe or something similar)
  4. "cd" to where plink.exe is
  5. Run the command:
    1. plink.exe -v git@bitbucket.org
  6. You will get verbose output of what putty does during it's connection and you can see what SSL key is used during the handshake.

If the connection is unsuccessful, the last few lines of the output will look something like this:

Offered public key
Server refused our key
Server refused our key
Disconnected: No supported authentication methods available (server sent: publickey)
FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)

If the connection is successful, you should see something like this:

Access granted
Opened channel for session
Server refused to allocate pty
Started a shell/command
conq: logged in as kyrra.

You can use git or hg to connect to Bitbucket. Shell access is disabled.
Server sent command exit status 0
Disconnected: All channels closed

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 1, 2013

Glad you figured this out, and thanks for posting such a comprehensive reply. It's useful that PuTTY lets you configure things at a finer level via this interface (handy for specifying aliases to specific setups for example) but it can definitely be a pain if you have some old settings lying around. The SSH key setting, either per alias/session or in the Default Settings overrides any other choice of key with no fallback so your diagnosis makes sense, although I can imagine it was a pain to locate.

Vladimir Knobel
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 27, 2017

You are a genius my problem was also the default settings specifically the port that was other than 22

Bryan Lamb
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 10, 2017

Thanks! This was my issue too.

Sbr3mb
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!
May 8, 2019

Wow, this was the problem. Thank you

Seth
Contributor
April 21, 2020

Answers like this make me wish I could upvote more than once. Thanks!

0 votes
thistlillo January 26, 2021

Unfortunately, this method does not cover all cases. Indeed, SourceTree keeps refusing to push (unauthorized) even if plink -v git@bitbucket.org succeeds.

0 votes
DylanAlloy June 27, 2020

I'm not even using SSH to auth with the Github server and it was working 5 seconds ago. 

I maximized from the taskbar to push something and it's magically not working anymore.

 

How can your software be so unstable?

0 votes
Jan Tancibok
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!
May 9, 2018

I have similar issue "FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)"

Solved when I do checkout with full uri, also with user like "ssh://USERNAME@bitbucket.org"

0 votes
Nick_Cipollina
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 22, 2013

I am having a similar issue. I'm getting that error message above, but I don't even use PuTTY. Any help in how to fix this would be appreciated.

Thanks,

Nick

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 22, 2013

SourceTree for Windows up to 0.9.1 actually only supports PuTTY as the SSH implementation. If you have OpenSSH keys in ~/.ssh instead then you can import them into PuTTY format, there's information on how to do this in the FAQ: http://sourcetreeapp.com/faq/ (at the bottom, 'How do I set up SSH keys')

We have a update pending which also allows the use of OpenSSH directly, although we still highly recommend PuTTY since it's more Windows-native and not designed primarily for terminal use like OpenSSH.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events