How to use TortoiseHg from command line without PuTTY (Pageant)

2.6k Views Asked by At

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 [email protected]

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?

3

There are 3 best solutions below

0
On BEST ANSWER

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

1
On

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.

0
On

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.