SourceTree error: The server's host key is not cached in the registry.
Asked by Markus Bonn:

In a brand new installation of SourceTree on a brand new WIndows 10 I am getting and error for push/pull/fetch etc :

    git -c diff.mnemonicprefix=false -c core.quotepath=false fetch originThe server's host key is not cached in the registry. Youhave no guarantee that the server is the computer youthink it is.The server's rsa2 key fingerprint is:ssh-rsa 2048 aa:d1:aa:00:bb:c0:b0:a0:d0:e0:f0:a0:a1:00:11:eeIf you trust this host, enter "y" to add the key toPuTTY's cache and carry on connecting.If you want to carry on connecting just once, withoutadding the key to the cache, enter "n".If you do not trust this host, press Return to abandon theconnection.

A solution to this is described here:

<https://confluence.atlassian.com/sourcetreekb/trust-a-server-s-host-key-when-no-button-is-available-to-trust-it-788731545.html>

But this does not resolve the problem. The solution offers two workarounds:

1) "Just get SourceTree to use Embedded Git and get it to trust the host"

When I do this I am not prompted to trust the host. It simply switches to Embedded without any more messages or confirmations.

2) Run the command

    "C:\Program Files (x86)\Atlassian\SourceTree\tools\putty\plink.exe" bitbucket.org

When I do this, I am indeed prompted to trust the server. After I enter yes, I am prompted for a login. I have no idea what to enter here. But any login I can imagine, such as for my bitbucket account fails :

FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)

BTW, the command line versions of the git commands work fine

Any help in this matter would be appreciated.


Answers:
author: Rachel Sutherland
body: I was able to fix this in Windows 11 by running the following code in the command line (Sourcetree is installed in a different location than most programs by default apparently):

```
"C:\Users\username\AppData\Local\SourceTree\app-3.4.8\tools\putty\plink.exe" bitbucket.org
```

Change "username" to your PC username, and change "app-3.4.8" to the appropriate folder with your version of sourcetree.

Then you'll get this:

```
?The server's host key is not cached. You have no guarantee
that the server is the computer you think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 SHA256:[removed - but this will show your rsa key]
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info)
```

Type y and click enter.

Then when it prompts for your login,

```
?login as:
```

...enter your bitbucket username and press enter.

I got this response (and pressed enter),

```
Access granted. Press Return to begin session.
Server refused to allocate pty
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled
```

...and was able to clone just fine after that.

comments: author: David Brady
body: Thank you very much. I have been banging my head for several hours with this problem. Two things that were different for me:

1. login as: did not work. I entered my bitbucket username and received "no supported authentication methods available". But it seems to have added the server's key.
2. I had to reboot the laptop. Until I did that I still could not clone. But after booting I could.

Thanks again!


author: Daniel Best
body: Yes! Lets go Rachel!  

I have been looking for that tools folder in my Sourcetree app for a full day now. If you are reading this with version 3.4.8 installed the article above not longer applies to you. you will need to use Rachel's instructions instead.  

Thank a bunch Rachel!


author: Katsuragawa Naoyuki
body: Thanks from Japan! I could resolve the same problem.


author: Andr? Saldanha
body: Feito!!

Muito obrigado. Funcionou aqui

Thanks from Brazil


author: Rachel Sutherland
body: I wanted to add an update because I recently tried to my repo for Sourcetree in a Parallels virtual machine, and got the same error that this person was mentioning above:

```
FATAL ERROR: No supported authentication methods available (server sent: publickey)
```

I decided to try using OpenSSH instead of Putty, and that fixed the issue. To do that, just follow the instructions under "Set up SSH for Git on Windows" at this link:  
[Set up an SSH key \| Bitbucket Cloud \| Atlassian Support](https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/)  

Note that you'll need to install Git for Windows if you want to run the commands outside of Sourcetree:  
[Git for Windows](https://gitforwindows.org/)  

After you've setup an ssh key with those instructions and verified the configuration, open sourcetree and go to Tools\>Options. Under the "General" tab select "OpenSSH" for the SSH client. You can then browse for your ssh key, which should be in:

```
C:\Users\username\.ssh
```


author: DUMAR HIDALGO
body: Hey!

I saw this answer right after solving the issue the exact same way. Thank you very much for posting it!


author: solutionengineers
body: I also had the same issue :(

Just running the "plink.exe" program, and answering "y" to adding to the cache, was enough to unblock Sourcetree :) I didn't need to log in or anything (I'd already set up my ssh key \& other info in SourceTree.


author: kevin monteclar
body: Thank you for posting this solved my problem!


author: Sundara Raman, Vidhyalakshmi
body: Switching to OpenSSH worked for me.   
Thanks from India!


author: ToM
body: Perfect, thank you very much!


author: Domicio.Medeiros
body: It is better to switch to open ssh. Much simpler to use. You can do that going to **Tools \> Options \> General**then change SSH Client to OpenSSH.


author: BAMxJustin
body: Thank you!!!


author: cityshark
body: Worked. Thanks :)


author: Jeremy Smith
body: I had the same error -- installing putty also fixes this fatal error.


author: John Khoury
body: thank you so much!!!!!


author: Rachael Affenit Hudson
body: Thank you so much, I've been trying to figure this out for several days \<3


author: CBI
body: Thanks !!!!!!!!!!!! \<3


author: Rico Steemers
body: Hey, y'all!  

If anyone in 2022 is getting this exact issue, I found another way that fixed it for me. I had the same scenario as the poster (Fresh Windows 11 installation) and I couldn't clone any repos  

So this is what I did  

**1.** Open SourceTree and navigate to Tools \> Options \> Authentication  
**2.** Click on your account and click "Set as default" *(Rest Saved Passwords \& Git Saved Passwords will appear)*   
**3.** Delete everything *(starting from the bottom, deleting Account last)* **4.** Restart SourceTree and go back to Authentication and add your account again  

Now, the cache prompt will properly appear while fetching your private key.  
This method may not work for everyone but it did for me ?

comments: author: Juancho Marengo
body: Thanks!!! Work's for me ?


author: Marvin.Nachatelo
body: For others that may be having the issue, this is how I was able to get past it.

I was able to correct this by downloading and installing putty onto my windows 10 laptop. I then made a connection to my git server and answered the question with a yes.

Marv

comments: author: RYAN
body: Thanks. You save my day!


author: C?dric PONSDESSERRE
body: Thanks too !


author: Sam Hayden
body: Worked for me, thanks!


author: Sandeep Kumar
body: Changed the SSH client from Putty to OpenSSH will work. you can go there Tools -\> General -\>SSH Client

comments: author: wei yuan
body: it's work for me ,think you very much


author: David Lukowski
body: Bump


author: Charles Robertson
body: This worked for me and is by far the easiest, least destructive solution.

I would suggest **everyone** tries this first, before deleting accounts etc, as suggested in a previous solution:

<https://community.atlassian.com/t5/Sourcetree-questions/Re-SourceTree-error-The-server-s-host-key-is-not-cached/qaq-p/2028547/comment-id/41794#M41794> ?

Thanks very much. ?


author: Brian Arizmendi
body: Worked for me too! Thank you very much


author: lfmcmillan
body: The solution didn't help me at all. It turned out all I needed to do was switch my SourceTree ssh client from Putty/Plink to OpenSSH and it immediately found my usual SSH key that I use for connecting to Github, and I was able to push from sourcetree etc.


author: grrbm2
body: Also another working solution (September/2022):  

if you were using a ssh key previously generated with "ssh-keygen", for example and that key

exists at path "C:\\Users\\\<username\>\\.ssh", you can import that key with PuTTy, and it will work.

Click Tools \> Create or Import SSH Keys,

then click "Load", on the popup choose file type "All Files" and choose your private key, usually called "id_rsa" (not id_rsa.pub - that's the public key)

It will load and tell you to click Save Private Key to save in putty's format (.ppk).

Do it and save the newly converted .ppk key, then run "pageant" (the thing that loads your ssh keys on sourcetree) - Tools \> Launch SSH Agent, then double-click its icon in the Notification Area.  

Load your converted key on Pageant by clicking Add Key and looking for "convertedKey.ppk".  

Done. Now you should be able to push via SourceTree !

<br />

<br />

![pageant.png](https://community.atlassian.com/t5/image/serverpage/image-id/218133iD07F7D11ABCF3E57/image-size/large?v=v2&px=999 "pageant.png")  

<br />

<br />

<br />

comments: author: grrbm2
body: Update: After testing a bit I found that PuTTy loses your key every time, and you have to reload it. A better option would be to just change the SSH client from PuTTy to OpenSSH  

(Tools \> Options then change SSH Client in SSH Client Configuration section)  

Now it works every time without problems.


author: solutionengineers
body: Bit of a late reply here... You're right that OpenSSH is better, in every single way: But you /can/ make PuTTy start up with a loaded key. Regrettably I can't recall exactly how (I've switched completely to Linux now \& as a result I can no longer use SourceTree - at least until Atlassian port it to Linux (PLEASE?)); but there's a command line option you can use... I put a shortcut into my startup folder which was something like 'putty.exe -o keyfile.key' (like I say, it's been a couple of years, the exact magic I cannot remember).

Hope that helps someone, especially if you've no choice but to use PuTTy.


author: Charlie Galik
body: I could not get passed this problem either (Windows 10 fresh install). HTTPS worked, but I needed SSH as well. The above solutions I could not get to work. What I ended up doing is opening up Putty, ssh into the server (remember to get username and port set right), trust the host by hitting "y". Then go back to Sourcetree and WIN! Maybe will help someone else too. Good luck!


author: ???
body: Thanks Rachel for sovling our issues. You really made my day!


author: Admin
body: Right on Rachael! Perfect solution and easy.


author: Martin Pro (Scalios)
body: For everyone who is struggling with this error on BitBucket **SERVER** (**on prem** ) or who has **Custom Ports**.

I wasted almost 2 days on this error, the important difference, at least for me, wasthat i constantly got an "access denied" error with the plink command.

I finally did it by coincidence, because i tried from another site this complete command with password included:

plink.exe -ssh -pw "YourPassword" username@YourOnPremBitBucketServerURL

The breakthrough was adding the port parameter -P. Our admin team choose 7999. I think most use 2222. You can find your port in BitBucket Admin / Server settings.

With the port it finally worked, here the complete command:

**plink.exe -ssh -pw "YourPassword" username@YourOnPremBitBucketServerURL -P YourPort**

<br />

Just for complete documentation, as many above wrote the plink.exe can be found in the install directory of SourceTree or Putty:

- SourceTree: C:\\Users\\USERNAME\\AppData\\Local\\SourceTree\\app-SOURCETREEVERSION\\tools\\putty

- Putty: C:\\Program Files\\PuTTY


author: adina-alexandra_Pinzaru
body: After running the following command i received : FATAL ERROR: Network error: Connection timed out.

```
"C:\Users\username\AppData\Local\SourceTree\app-3.4.8\tools\putty\plink.exe" bitbucket.org
```

Do you have any idea?

Thanks


author: Wahab Hussain
body: Try opening the terminal by going into Action --\> Open In Terminal  
Then within the terminal paste the git repo URL you will be prompted to accept the server finger print.

Type yes and enter. Server fingerprint will be cached.


author: Domicio.Medeiros
body: It is better to switch to open ssh. Much simpler to use. You can do that by going to **Tools \> Options \> General**then change SSH Client to OpenSSH.


author: hegedus.g
body: Should anyone still care:

Exact same error message (y/n cache stuff) deleting the local repo and **recloning** of those with such error msg helped me out......


author: Sean Lively
body: [@Daniel Eads](/t5/user/viewprofilepage/user-id/1527694) Since we can't report bugs anymore: <https://community.atlassian.com/t5/Sourcetree-questions/how-do-i-report-a-bug-in-sourcetree/qaq-p/1164591>

Is this issue in your bug tracker anywhere? I had this exact problem today with a new developer, fresh Windows 10 install, fresh SourceTree install.


author: Otemu Akpobaro
body: This is the method that worked for me, taken from stack overflow:

The way to add bitbucket as a host to PuTTY's cache is to run the

following command:

**plink.exe bitbucket.org**

Just answer y, and then Ctrl+C, ignore the rest

[Original Source](https://stackoverflow.com/questions/4931384/git-server-host-key-not-cached#answer-12448986)


author: tregdor
body: I'm struggling with this as well. The command line plink caching technique has worked elsewhere but for whatever reason I have one machine on which this doesn't work. git bash finds credentials and repeated plink suggests that it finds the cached key as well. Only sourcetree believes the key is not cached. Using the embedded git does not change anything.

Using SourceTree 3.4.9

comments: author: Christopher Berger
body: For me worked what others have already pointed out.

Run the following command, replace \<DestinationFQDN\> with your actual server address.

%LOCALAPPDATA%\\SourceTree\\app-3.4.9\\tools\\putty\\plink.exe \<DestinationFQDN\>

e.g.

%LOCALAPPDATA%\\SourceTree\\app-3.4.9\\tools\\putty\\plink.exe gitlab.contoso.lan


Tags: atl-orange