ndbeals/winssh-pageant

Not working for me on SourceTree (Windows 11)

jmadren opened this issue · 5 comments

I have the Microsoft Windows OpenSSH agent running and properly configured. It has saved the passphrase so I can ssh into my server without prompting for the passphrase, even after logout or restart.

I installed winssh-pageant, verified it's running (Task Manager shows the bridge), set SourceTree to use PuTTY/Plink for the SSH client and unchecked "Automatically start...".

But when trying a Pull or Fetch in SourceTree it just sits there forever. Showing the full output displays this:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch --no-tags SiteGround
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 ssh-ed25519 key fingerprint is:
ssh-ed25519 255 SHA256:cn4m9+WKTb2bzO/5wynxu6dtJ6ILWTprpc+cHBzLfvE
If you trust this host, enter "y" to add the key to

So it seems to be waiting for a response, but I can't respond from within SourceTree.

I also found that if I refresh the remote branch list in the Pull dialog, the list is emptied, and I can't initiate a pull at all. So it does not look like SourceTree/git is able to communicate with the server at all.

I tried importing the SSH key and saving it as a ppk and setting that in SourceTree options, but still no go.

SourceTree was working before, using its (or git's) ssh client, but of course it always asks for the passphrase after logging out or restarting. Hence why I am trying winssh-pageant, but can't get it to work.

Any ideas?

It appears to be hanging because the server's host key has never been cached (AKA sourcetree thinks you've never interacted with that server using ssh before).

Can you try running that git command git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch --no-tags SiteGround directly from your command line? It should giver that same message about pressing y to trust this host. Once the key has been cached this shouldn't be an issue for you any further. Or try connecting to your git repository directly from the PuTTY UI, you don't need to actually log in, just have putty open a window asking you to confirm the key is valid.

I try not to point fingers but this isn't exactly an issue with winssh-pageant, all it does is proxy the key requests to the proper location, which only happens after you've confirmed you trust the ssh server. WinSSH-Pageant hasn't even been engaged yet according to your log paste.

Take a look at these following links, you're not the only one who's faced this problem. In order of how helpful I think they may be.

It appears to be hanging because the server's host key has never been cached (AKA sourcetree thinks you've never interacted with that server using ssh before).

As I stated, I can ssh into the server without issue, and without entering the passphrase.

Can you try running that git command git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch --no-tags SiteGround directly from your command line? It should giver that same message about pressing y to trust this host.

Tried this - no message or any output at all. Just runs for a second then returns to the command prompt. (edit: no response could be because my local repo was already up-to-date, so nothing to do. But as stated below, I don't know a lot about git)

Or try connecting to your git repository directly from the PuTTY UI, you don't need to actually log in, just have putty open a window asking you to confirm the key is valid.

I don't have a PuTTY UI. But your first link helped me find plink in the SourceTree folder, and using that to connect to the server did give me the message. After confirming to save the key, now SourceTree is working!

I try not to point fingers but this isn't exactly an issue with winssh-pageant, all it does is proxy the key requests to the proper location, which only happens after you've confirmed you trust the ssh server. WinSSH-Pageant hasn't even been engaged yet according to your log paste.

I don't quite follow this. I don't know a lot about git/ssh and I know nothing about PuTTY, except using it years ago to connect to some networking gear on Windows. As stated already, my ssh (the system ssh) already "trusts" the server. The issue to me seems to be that even though WinSSH-Pageant proxies the requests, it (SourceTree) still uses putty to initiate some things, and this key caching/trust thing is part of that. So, for people like me who never used the PuTTY client with SourceTree (or anything else), but only SSH from the get go, this will be an issue. You should include such instructions in the readme for WinSSH-Pageant.

Thanks for you help, and for WinSSH-Pageant!

Glad to hear you got it worked out, thanks for the kind words.

joepb commented

@jmadren Could you elaborate how you fixed it? I don't see any plink anything and I'm running into exactly the same issue.
On the commandline everything works all nice and happy, but Sourcetree refuses...

@joepb Been a while since I did this, so had to piece together my notes. Here is the entire process I used (just in case the other steps may be relevant):

Verify OpenSSH client is installed - On Window 10: Apps > Apps & Features > Optional Features; on Windows 11: Apps > Optional Features.

In Services app, enable and start "Windows OpenSSH Authentication Agent" (ssh-agent).

In a Command window, run ssh-add <path to remote host key> to add key and save passphrase (will be prompted for passphrase).

Install WinSSH-Pageant from a Command window: winget install winssh-pageant.

Verify "WinSSH-Pageant Bridge" is running in Task Manager.

Go to SourceTree program folder, then find the "tools" folder which has a "putty" folder (may be in an "app-X.X.X" folder). In a Command window change to the putty folder and run plink -P 18765 <user>@<hostname> and respond "y" to save the key.

Open SourceTree and in Options set SSH Client to PuTTY and uncheck "Automatically start..."
(note: may have to import the host key and save as a ppk to use in the SSH Key field here).

Logout of Windows then log back in to verify SourceTree still functions and no longer asks for passphrase.

Edit: escaped shell commands to prevent conversion of symbols.