4

Earlier I used Mercurial command line installation and it worked fine for me with default ssh client and keys location in ~/.ssh.

On my new laptop I installed TortoiseHg. Now any remote request (like hg pull, or hg incoming) generates PuTTY Fatal Error:

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

enter image description here

Quite similar result if i try to acces repository over ssh directly: ssh -vT git@bitbucket.org

The problem may be solved using Pageant (plink): run it and add putty key, or add pageant (plink) to Mercurial config file.

BUT, i'm looking how it is possible to work in old way, without pageant or plink, using only default ssh keys location?

radistao
  • 14,889
  • 11
  • 66
  • 92
  • Have you tried using HTTPS instead of SSH? – Kevin Aug 12 '15 at 18:27
  • i need ssh, not https – radistao Aug 12 '15 at 18:31
  • Bitbucket supports HTTPS just fine. – Kevin Aug 12 '15 at 18:32
  • the problem is not related to Bitbucket, but to TortoiseHg – radistao Aug 12 '15 at 18:33
  • TortoiseHg also supports HTTPS. – Kevin Aug 12 '15 at 18:33
  • 2
    Are you Troll? Why didn't you propose me to use git? Which also works fine with Bitbucket and HTTPS. The question is concrete and clear: ssh in TortoiseHg. Not other protocols, applications or repositories. – radistao Aug 12 '15 at 18:41
  • Windows does not do the whole "put random dotfiles and folders in the home directory" thing; there is no `~/.ssh`. You put stuff in %APPDATA%. And if your stuff is not associated with an app in the first place, there isn't anywhere to put it. I was trying to find a solution that would work for you, since you appear to be asking for functionality which does not exist. – Kevin Aug 12 '15 at 20:21
  • You can SSH with [Cygwin](https://www.cygwin.com/) on Windows, and run `hg` inside Cygwin. If you're trying to connect *to* a Windows box via SSH, you can [setup `sshd` via Cygwin](http://kris.me.uk/2010/08/27/sshd-and-cron-on-windows-using-cygwin.html). Apologies if this isn't related to your question, if this doesn't help I'm afraid I don't understand what you're asking. – dimo414 Aug 12 '15 at 20:49

3 Answers3

11

Looks like opposite to git Mercurial does not provide own ssh client, so using Plink and Pageant is mandatory, except two workarounds:

  1. Use TortoisePlink as ssh client with explicit key reference in Mercurial config (%USERPROFILE%\.hgrc or %USERPROFILE%\Mercurial.ini):

    [ui]

    ssh = "C:\Program Files\TortoiseHg\lib\TortoisePlink.exe" -ssh -i %USERPROFILE%.ssh\id_rsa.ppk

  2. If you have installed git or cygwin (or any other way to use ssh on Windows), it is possible to use third party ssh client pointing path in Mercurial config:

    [ui]

    ssh = "C:\Program Files (x86)\Git\bin\ssh.exe"

    # or

    # ssh = "PATH_TO_ANY_OTHER_SSH_CLIENT_LIKE_CYGWIN"

I tried both ways -- they work excellent.

I use second one, because I use git distributed tools on my PC as main ssh agent. First option is suitable if you don't have ssh alternative on your PC.

Notes:

  • Some times, based on parser, paths in ini files parsed with characters eascaping, so \ may escape next symbol. In this case the path should look like C:\\Program Files (x86)\\Git\\bin\\ssh.exe (with double-slashes)
  • I have git\bin directory in my %PATH% variable to use ssh without full path specifying. In this case in Mercurial config you can use just like this:

    [ui]

    ssh = ssh

radistao
  • 14,889
  • 11
  • 66
  • 92
2

No, there isn't any way to do this without installing or using some software other than TortoiseHg itself.

Mercurial does not implement SSH itself. On Unix, it just runs ssh and expects to have a suitable client already installed (which is a safe bet since the vast majority of Unix systems either have an SSH client preinstalled or can have one installed relatively easily). On Windows, that's not a reasonable assumption, so TortoiseHg bundles a client:

SSH is a symmetrical peer-to-peer secure tunnel. SSH clients and servers have their own key management systems, so Mercurial does not get involved with password prompts when SSH is used. This is problematic on Windows and thus TortoiseHg bundles the TortoisePlink SSH client with its Windows installers. TortoisePlink is a port of the Plink SSH client that uses dialog prompts for host-key authorizations and passphrase prompts. TortoisePlink (developed by the TortoiseSVN project) can use the other SSH tools that are part of the Plink toolchain, including the Pageant key agent.

If you do not use TortoisePlink, you most likely do not have an SSH client which TortoiseHg is capable of interfacing with. And if you do not use Pageant, there's no system for saving your keys; TortoisePlink does not use ~/.ssh because that's not how Windows does things.

Kevin
  • 28,963
  • 9
  • 62
  • 81
  • That's not how `TortoisePlink` does things. Windows doesn't care, and putting an .ssh dir in %USERPROFILE% could work just fine on Windows. – codekaizen Mar 11 '16 at 21:55
0

How do I prevent “No supported authentication methods available” error when using TortoiseHg?

Get/Run puttygen.exe , click Generate, (no passphrase), before you close the window, Save pubkey, Save PrivKey. Copy all the key text, (or you will have to go back into puttygen) and paste it into the Account/Profile/Settings/Security/SSHKeys area on BitBucket webpage. (right click) pageant.exe icon in systray - Click "Add Key". Exit pageant and reload it just to make sure. Exit tortoise and reload it just to make sure. Good to go.

Community
  • 1
  • 1