Connect to mercurial via ssh on windows - windows

Can anyone point me in the direction of a simple step by step guide as to how to connect to a mercurial repo via ssh on windows. Im really struggling to get my head around it, and so far i jus keep getting a string of errors. Any help would be appreciated.

take a look at this http://www.codza.com/mercurial-with-ssh-setup-on-windows

Assumes: you have a putty suite installed, a ppk and using TortoiseHg.
Here is my original c:\somerepo\.hg\hgrc file:
[paths]
default = ssh://hg#bitbucket.org/someuser/somerepo
So what's happening with ssh? Let's debug a pull statement, hg pull --debug on the command-line. I noticed it is running C:\Program Files\TortoiseHg\lib\TortoisePlink.exe instead of ssh to make the call:
PS C:\somerepo> hg pull --debug
pulling from ssh://hg#bitbucket.org/someuser/somerepo
running "C:\Program Files\TortoiseHg\lib\TortoisePlink.exe" -ssh -2 hg#bitbucket.org "hg -R someuser/somerepo serve --stdio"
sending hello command
sending between command
abort: no suitable response from remote hg!
So let's just reuse the call, add compression (yay!), non-interactive (batch) and our key:
[paths]
default = ssh://hg#bitbucket.org/someuser/somerepo
[ui]
ssh = "C:\Program Files\TortoiseHg\lib\TortoisePlink.exe" -ssh -2 -C -batch -i "c:\keys\somekey.ppk"

Related

git clone with SSH only working in Git Bash not on Windows CMD

So, I've followed this tutorial on how to Setup SSH for github with Windows CMD and all was working fine until I went to clone a repo with
git clone git#github.com:{myusername}/{myrepo}.git
Where I get
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Even when I run ssh -T git#github.com I get the expected message telling me I'm authenticated.
After scratching my brain for a while, I decided to try it on git bash.
First thing I noticed was that running
ssh-add -l
in git bash, I was getting The agent has no identities. but when I run the same command on Windows CMD I get all my SSH keys?
So, after adding my ssh key in git bash I was able to clone my repository.
So, why is it only on git bash I can do this and not on the cmd or powershell? Is it something to do with what seems like they are using different ssh agents? How can I sync them together if that is the case?
Furthermore, when I run the following command
ssh -Tv git#github.com
with the cmd I get
debug1: identity file C:\\Users\\{myuserdirectory}/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
but with git bash I get
debug1: identity file /c/Users/{myuserdirectory}/.ssh/id_rsa type 0
Another difference is that in windows cmd I don't get any instances of
debug1: Will attempt key: ....
When I exit git bash and open up another git bash terminal, running ssh-add -l again, it returns The agent has no identities. even after I added it before, it's like it only persists for each session, which also isn't desirable.
Any help with this would be greatly appreciated!
Probably you were right and they were using different ssh-agents. I had exactly the same problem and this answer helped me a lot:
https://stackoverflow.com/a/40720527/6486458
By default git refers to its own ssh in C:\Program Files\Git\usr\bin. I added GIT_SSH environment variable and set it to C:\Windows\System32\OpenSSH\ssh.exe. This prevents inconsistency between the versions of ssh. After that git started to work as expected from both Git Bash and Windows cmd.
From git documentation:
GIT_SSH, if specified, is a program that is invoked instead of ssh
when Git tries to connect to an SSH host. It is invoked like $GIT_SSH [username#]host [-p <port>] <command>.
See also this answer: https://stackoverflow.com/a/8713121/6486458
Looks like your ssh-agent is not running or not recognize your ssh key
try this:
# add the default ~/.ssh keys to the ssh-agent
ssh-add
# restart the ssh-agent
eval $(ssh-agent)
# On windows:
start-ssh-agent
ssh-add
ssh-add adds RSA or DSA identities to the authentication agent, ssh-agent.
When run without arguments, it adds the files ~/.ssh/id_rsa, ~/.ssh/id_dsa and ~/.ssh/identity.
Alternative file names can be given on the command line
There is a weird bug on Windows if you install Git bash. Open Command prompt, and do
ls ~/.ssh
if you find this folder already created, then copy the public and private key from your user folder to this path:
cp C:\Users\username\.ssh\id_* ~/.ssh/
For some reason, windows command prompt creates this path the first time you do a git clone, and after that it just requests for git#gitlab / git#github password.

Can't launch putty with remote command?

I'm attempting to launch putty via the command line in such a way that it runs a command on the server (I want to create a windows shortcut, to tail a log file)
So far I have a batch file containing this
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh -t -pw -m tail_catalina_out -load "myprofile"
And within my server I have a file at the root directory named tail_catalina_out with the following contents.
tail -f /opt/tomcat/logs/catalina.out
Putty launches and my session starts successfully, but no command appears to be carried out despite this? Am I misunderstanding how this works?
You don't need -ssh with -load profile (and if you use a nonstandard port like my test it doesn't work at all); in fact you don't need it with [user#]host because it's the default
-pw -m tail_catalina_out uses -m as your password (which I hope is incorrect, so you should be reprompted unless publickey auth is set-up) and ignores tail_catalina_out
the file for -m must be local i.e. on the PuTTY machine not on the server (although the commands in it will be sent to, and must be valid on, the server)
Thus: "\path\to\putty" -t -m localcmdfile -load profile
You could also use plink which runs in the console and takes either -m localfile or the actual remote command on the command line after the last option (like the OpenSSH client ssh):
"\path\to\plink" -t -load profile tail -f remotefile
As usual, you can omit the quotes around the path if it contains no space. Personally I use \progra~2 instead of bothering with "\program files (x86)" but that's just me, and it may depend on a clean install (instead of upgrade).

Git clone / pull continually freezing at "Store key in cache?"

I'm attempting to clone a repo from my BitBucket account to my Windows 10 laptop (running GitBash). I've completed all of the steps necessary to connect (set up my SSH key, verified by successfully SSHing git#bitbucket.org, etc). However, whenever I attempt to clone a repo, the prompt continually hangs up after confirming that I want to cache Bitbucket's key.
User#Laptop MINGW64 /C/Repos
$ git clone git#bitbucket.org:mygbid/test.git
Cloning into 'test'...
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
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) y
No files are cloned, and the result is an empty repo. Trying to initiate a git pull origin master from this repo also asks to cache the key, then hangs with no feedback. Despite not asking for the key to be cached when I do a test SSH, git operations always ask for the key every time before failing.
With no error messages to work with, I'm really at a loss as to what is wrong. I've tried multiple repos, including very small ones, with no success at all.
I had this problem when cloning a repo on Windows 10 too.
I got around it by using the Putty GUI to SSH to the server in question (in your case: bitbucket.org) then clicked 'Yes' when the prompt asks if you want to save the server key to the cache. Running the clone command again then worked for me!
Open Putty
Type in the Host Name (like bitbucket.org)
Click Open
Click yes in the popup to cache the host key
Close Putty
I managed to get it working by running plink directly, after pageant is running use the plink command directly - plink.exe -agent -v git#github.com then after this git works without hanging.
To do this from powershell open a powershell window and paste in the following:
echo y | & 'C:\Program Files (x86)\GitExtensions\PuTTY\plink.exe' -ssh git#github.com
echo y | & 'C:\Program Files (x86)\GitExtensions\PuTTY\plink.exe' -ssh git#gist.github.com
echo y | & 'C:\Program Files (x86)\GitExtensions\PuTTY\plink.exe' -ssh git#bitbucket.org
or with PuTTY standalone version:
echo y | & 'C:\Program Files (x86)\PuTTY\plink.exe' -ssh git#github.com
echo y | & 'C:\Program Files (x86)\PuTTY\plink.exe' -ssh git#gist.github.com
echo y | & 'C:\Program Files (x86)\PuTTY\plink.exe' -ssh git#bitbucket.org
Also worth knowing is that putty stores known hosts under a registry key:
HKEY_CURRENT_USER\SoftWare\SimonTatham\PuTTY\SshHostKeys
To shortcut the above you could put the following in a .reg file and run it:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\SshHostKeys]
"rsa2#22:github.com"="0x23,0xab603b8511a67679bdb540db3bd2034b004ae936d06be3d760f08fcbaadb4eb4edc3b3c791c70aae9a74c95869e4774421c2abea92e554305f38b5fd414b3208e574c337e320936518462c7652c98b31e16e7da6523bd200742a6444d83fcd5e1732d03673c7b7811555487b55f0c4494f3829ece60f94255a95cb9af537d7fc8c7fe49ef318474ef2920992052265b0a06ea66d4a167fd9f3a48a1a4a307ec1eaaa5149a969a6ac5d56a5ef627e517d81fb644f5b745c4f478ecd082a9492f744aad326f76c8c4dc9100bc6ab79461d2657cb6f06dec92e6b64a6562ff0e32084ea06ce0ea9d35a583bfb00bad38c9d19703c549892e5aa78dc95e250514069"
"rsa2#22:gist.github.com"="0x23,0xab603b8511a67679bdb540db3bd2034b004ae936d06be3d760f08fcbaadb4eb4edc3b3c791c70aae9a74c95869e4774421c2abea92e554305f38b5fd414b3208e574c337e320936518462c7652c98b31e16e7da6523bd200742a6444d83fcd5e1732d03673c7b7811555487b55f0c4494f3829ece60f94255a95cb9af537d7fc8c7fe49ef318474ef2920992052265b0a06ea66d4a167fd9f3a48a1a4a307ec1eaaa5149a969a6ac5d56a5ef627e517d81fb644f5b745c4f478ecd082a9492f744aad326f76c8c4dc9100bc6ab79461d2657cb6f06dec92e6b64a6562ff0e32084ea06ce0ea9d35a583bfb00bad38c9d19703c549892e5aa78dc95e250514069"
"rsa2#22:bitbucket.org"="0x23,0xb9b88df3578371a7eb80c78bcda14fb30da436f11ca932a5fd5a8b6adfcc681df7a59cb4cb7ac966d9eac11daa38ebdbc0a6582a210ed4ee95a8d101c4abc925e942ab47535d64f9a5b3b68035c2ea1e900d709a1e8ea938718f532f9805a190446b92bac3040126225ae9d8374bc2008f106979d631734c7453f78c70091f4783b288869cb3c1941a784cd9baad823be27333833dc1f488a45b85952be75cf0a64965662302e3915378dcd5cfcd3ec903d804a29dff2fdf19df5deba4534b09e4dea6e44f152e339b3c43be98ddadfc56533192e216a3d673f00b4aa9cc9e7870acd8b6adb7e0feb77f2292fc2dede94819def3eb1e785541a06ab31ccf725f"
putty-hosts.reg gist
To workaround this problem I configured GitBash to use plink with -batch option. The option disables all prompts - the plink will terminate without hanging and won't add any key fingerprint to cache.
To add -batch parameter to plink command executed by GitBash you can set a git config option:
git config --global core.sshCommand "plink -batch"
Or set GIT_SSH_COMMAND environment variable.
The output when you cloning a repo from unknown host will be similar to this:
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
Connection abandoned.
fatal: Could not read from remote repository.
After this message you can add a key to cache with command:
echo y | plink git#bitbucket.org
REMARK: Please check if plink is in your PATH. Alternatively use UNIX-like path in the GitBash config option, e.g.:
/c/Program\ Files/PuTTY/plink.exe -batch
Even after performing the workaround mentioned in other answers, you may encounter an error like:
FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
To solve both problems at once, change git bash to use SSH instead of PuTTY by adding the following to your ~/.profile file (C:\Users\<Username>\.profile). If you don't already have this file, then create a new file with this line.
GIT_SSH="/usr/bin/ssh.exe"
Then open a new git bash window and try your git clone or git pull again.
Note that this may require you to create an SSH key if you don't already have one. To do this, follow the instructions on the Bitbucket site.
See this SO question for related info.
In your git bash shell, check for existence of GIT_SSH:
echo $GIT<tab><tab>
If it exists and is set to putty, execute:
unset GIT_SSH
You'll probably want to put this into one of the git bash startup scripts.
This is NOT a universal solution. It worked in our particular case.
It sounds a bit silly, but after trying all of the above, I decided to reinstall Git Bash with default options and it worked.
If you use KiTTY (instead of PuTTY), it has -auto-store-sshkey argument.
So, you can set GIT_SSH_COMMAND (or git config --global core.sshCommand) to something like c:/KiTTY/klink.exe -auto-store-sshkey.
The output still contains information about new key and the question, but it doesn't wait for the answer:
The server's host key is not cached in the registry. 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 2e:65:6a:c8:cf:bf:b2:8b:9a:bd:6d:9f:11:5c:12:16
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)
Autostore key is on
Default SSH port to connect to is 7999

Windows TortoiseHg plink hangs AFTER clone/push

We have an all Windows network and I'm trying to get Tortoise Mercurial up and running over SSH for a central repo for our small team to use. I can get it working for the most part but plink/tortoiseplink hang AFTER executing commands successfully (clone/push etc.)
I've set up Freesshd on our Widnows 2008 rc2 server along with Tortoise Hg. I've generated myself a public/private key on the server (was having issues generating on the client) using PuttyGen. Private key I copied to my client and updated mercurial.ini. Public key I renamed and updated Freesshd to point at the folder containing the public keys.
On the client side I have registered my private key with Pageant, created a session in Putty along with pointing it at my private key and saved it.
When I use Putty to make my initial connection, things start to go odd.
I get a command prompt for user name (no prompt for password) and, at the command prompt (after authentication), I can't type.
Perhaps an issue with Putty. I'll try using Tortoise via (TortoisePlink.exe).
In mercurial.ini I have:
[ui]
ssh = "C:\putty\TortoisePlink.exe" -ssh -2 -batch -C -i C:\Users\Jude.ssh\JudePrivate.ppk
If I use the console I can clone the repo but it hangs AFTER doing everything. Using --debug, the last line is:
3 files updated, O files merged, 0 files removed, 0 files unresolved
Kind of what I would expect as the files do get clones. But then I can't do anything else. Ctrl+C does nothing and I have to kill the process. (Which by the way, then shows the Ctrl^C at the command prompt as well as the rest of the keyboard mashing).
The repo gets cloned, the correct version of the files appear but the console window doesn't close or give me back control.
If I try using the Hg Workbench, I get a similar issue. I can clone and push - it actually happens - but using the GUI I get:
% hg --repository C:\repositories\HgTest push --debug
ssh://Jude#dev01:22/d:/repositories/hgtest
pushing to ssh://Jude#dev01:22/d:/repositories/hgtest
running "C:\putty\TortoisePlink.exe" -ssh -2 -batch -C -i
C:\Users\Jude\.ssh\JudePrivate.ppk Jude#dev01 -P 22 "hg -R d:/repositories/hgtest serve --stdio"
sending hello command
sending between command
remote: 145
remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
remote: 1
query 1; heads
sending batch command
searching for changes
all local heads known remotely
no changes found
sending listkeys command
checking for updated bookmarks
sending listkeys command
The green bar at the top of the Workbench says "Pushing to ssh://Jude#dev01:22/d:/repositories/hgtest..." as does the status bar at the bottom. I left it like this all weekend and when I came back it was still like it. I can still use the Hg Workbench (kind of) but can't use pull/push/clone. Trying to close the Hg Workbench results in the message (in status bar) Sync tab cannot exit and I can't close the app. Killing TortoisePlink.exe (or Plink.exe, whichever I try) frees up the app I can use it or close it as normal.
Initially I thought it was a problem with TortoiseHg or TortoisePlink but downloading Plink from the Putty site results in the same.
To clarify:
- I can push/clone via SSH and no password prompt
- I can do this via the command line or the Hg Workbench
- Irrespective of which method I use (or Plink.exe or TortoisePlink.exe) the process needs to be manually killed.
Software used + versions
Client (Windows Vista 32bit)
Tortoise Hg 2.3 (merc 2.1, Python 2.6.6)
Plink 0.62
Server - (Windows 2008 server rc2)
FreeSSHd 1.2.4
Same Tortoise as above
Lots of searching has yielded nothing of use. I've tried all suggestions I've seen (even if marginally related) but to no avail. As the actual functions are working I assume I've set up correctly the keys, SSH, Tortoise etc.
I'm hoping I'm missing a simple option somewhere but I suspect that it's awaiting some kind of user prompt.
Fingers crossed :)
=== UPDATE ===
I've found the event log for Putty (right click putty console window, voila, "Event Log" option. Once I've loaded the session and clicked open, I get the console window and a login as: prompt. After typing my name and hitting return, I get:
Reading private key file "C:\Users\Jude\.ssh\JudePrivate.ppk"
Pageant is running. Requesting keys.
Failed to get reply from Pageant
Offered public key
Offer of public key accepted
Sent public key signature
Access granted
Opened channel for session
Allocated pty (ospeed 38400bps, ispeed 38400bps)
Started a shell/command
And it's at this stage I the command prompt changes to c:\Windows\system32> and can't type anything.
=== UPDATE 2 ===
Using plink I do the following at the console:
plink -v -ssh Jude#dev01 "cmd /c echo hello"
and, as well as all the info -v gives, I see hello then Server sent command exist status 0 and Disconnected: All channels closed. This is what I would expect.
If I do it with tortoiseplink, `tortoiseplink-v -ssh Jude#dev01 "cmd /c echo hello"' I see nothing returned or written to the window and I get a command prompt again.
This implies SSH is working as is the alias (dev01). But should I see something when using TortoisePlink?
Typing hg clone --verbose -- ssh://Jude#dev01/d:/repositories/hgtest C:\repositories\test again fetches the files, copies them to the test folder but then doesn't return the command prompt. Last line is 3 files updated... etc.
=== UPDATE 3 ===
It seems hg.exe is spawned by FreeSSHd on the server and it does close/finish. When the hg.exe process is killed on the server, the client (console/clone dialogue box) behaves and finished the command gracefully.
To clarify:
I use clone from command line or HG Workbench and specify repo alias
According to the logs everything is fine, I'm authenticated, the files are pulled down via SSH and copied to the local repo I specified in 1
At this point it hangs - whether the console or HG Workbench or right click/clone option.
Using Process Explorer on the server allows me to kill hg.exe spawned by the FreeSSHd service
As soon as I do this the client says "command completed successfully".
So, it now seems to be an issue with Tortoise Hg on the server. Maybe FreeSSHd and Tortoise don't play well together... I suppose I'll reinstall everything...
=== UPDATE 4 ===
It seems I'm not the only one with this issue. I had spotted this before on SO but it wasn't relevant at the time. However, now I'm getting the same problem: Mercurial over ssh client and server on Windows
That problem wasn't solved (two years ago) so shall I keep this question open?
First of all - read docs!
hg help urls
Valid URLs are of the form:
....
ssh://[user#]host[:port]/[path][#revision]
Plink uses -l option for username
Debug successful ssh-connect (and usable path) with pure TortoisePlink, remove all unnecessary options

Mercurial over ssh client and server on Windows

I'm trying to configure Mercurial for use with both a windows server (freeSSHd) and client (both command line and TortoiseHG). I'm using the most recent versions of everything... all downloaded in the past few days. Using public key auth, I have been able to get connected to the server and I'm able to use plink to execute "hg version" and get a response, but when I try to clone a repository from the ssh server the command appears to hang. Running with -v yields:
hg -v clone ssh://<username>#<server>//hg/repositoryA testRepositoryA
running "plink.exe -i "<path to private key file>" <username>#<server> "hg -R /hg/repositoryA serve --stdio""
with nothing more forthcoming. Running the hg serve command directly on the server yields an apparently responsive Mercurial server, but the clients do not seem to make any further requests.
Running "hg serve" in the repository directory and cloning over http works perfectly.
What should I be looking for to help debug this? Is there something the clients (hg and TortoiseHG) aren't sending to continue the request stream?
Additional Information:
If I change to an invalid repository on the target machine, the appropriate error is displayed, so it does appear that the remote hg is running and correctly evaluating the path.
Running with --debug and --traceback results in:
sending hello command
sending between command
It hangs here, until I CTRL-C
Traceback (most recent call last):
File "mercurial\dispatch.pyo", line 46, in _runcatch
File "mercurial\dispatch.pyo", line 452, in _dispatch
File "mercurial\dispatch.pyo", line 320, in runcommand
File "mercurial\dispatch.pyo", line 504, in _runcommand
File "mercurial\dispatch.pyo", line 457, in checkargs
File "mercurial\dispatch.pyo", line 451, in <lambda>
File "mercurial\util.pyo", line 402, in check
File "mercurial\commands.pyo", line 636, in clone
File "mercurial\hg.pyo", line 187, in clone
File "mercurial\hg.pyo", line 63, in repository
File "mercurial\sshrepo.pyo", line 51, in __init__
File "mercurial\sshrepo.pyo", line 73, in validate_repo
KeyboardInterrupt
interrupted!
Responding to Ryan: There does not appear to be any CPU usage or increasing memory usage on the server. It appears to be waiting for the client to send a request or something similar.
11/19/2009 : More information:
The problem is definitely in the freeSSHd/server side of the equation. Connecting to bitbucket over ssh with the same keyset works fine. Still working on this.
The solution that worked for me was disable the "Use new console engine" option which is inside the SSH tab. Another thing is the path. ssh://ssh_user#SSH_Server_Address:SSH_Port/Win_Drive_Letter:/Path_To_HG_Repository
A concrete example:
ssh://programmer#192.168.1.150:5522/D:/Repository/MyProyect/trunk
I currently use MercurialHG not the CLI. I hope that this help
JQ
The solution actually I got it from here
I got the same symptoms just now, although hg was a bit more helpful after Ctrl+C - apparently plink was waiting for me to say y/n to "save server to cache". Unfortunately hg couldn't pass my y/n to it interactively (nor tell me that plink printed something important...)
Solution:
plink to the host once and save server info to cache
add -batch to the plink command line so that next time this happens it aborts instead.
I also add my key to pageant so I don't need to type the password anywhere else.
Complete example of .hgrc file (Win+R, notepad %USERPROFILE%\.hgrc):
[ui]
ssh=C:\Path\To\plink.exe -C -batch -ssh -i C:\Path\To\My\putty-private-ssh-key.ppk
Another option would be to try the Cygwin versions of hg and ssh. You can log SSH problems in that version with the -e option; for instance, hg clone -e 'ssh -vvv' ssh://you#server/repo...
I ran into this same problem. Not sure how it relates to yours, but this is what worked for me.
First, I will explain my set up.
I have a repository on my live site mysite.com
I have a local repository on my local machine in a folder mysite.com
I have other repositories, so I add [ui] settings to /.hg/.hgrc file in each repository folder on my local machine instead of the Mercurial.ini file.
First, if you have already connected via Putty, save the session because Plink can use stored sessions. Use Pageant and add your key.
Try running plink from the command line to connect using the stored session. For example, I saved my session as "mysite" in Putty.
C:\>plink mysite
Using username "mysite".
Last login: Fri Feb 26 21:16:05 2010 from ca-xxx-xx-x-xxx.sta.host.net
←]0;mysite#server:~[mysite#server ~]$
If that is working, try the following in your .hgrc file
[path]
default = ssh://mysite#myhost
[ui]
username = RB <admin#mysite.com>
ssh=plink.exe -ssh -i mysite
Plink is set in my PATH, and since the mysite session was already stored in Putty, it knows what to look for.
I was trying to do a pull, so I was testing using:
hg pull --debug --traceback
Hope that helps.
Edit: Sorry, saw too late you were using tortoiseHG instead of putty. Hope it helps anyway.
In my case I was able to connect to my server once but the second time it failed.
I have the same setup and it worked perfectly...but only once. There is nothing in my stored sessions.
[ui]
ssh=C:\Path\To\plink.exe -C -batch -ssh -i C:\Path\To\My\putty-private-ssh-key.ppk
Perhaps it's the case that 'hg' isn't in the path. You can see from the command line that's being invoked that 'hg' is being run as 'hg', which means it has to be in the server's path. Try using the --remotecmd option to clone to give the full path to the hg executable on the server (good luck getting the windows quoting right).
It's possible that your plink hg version test works because it's launched as an interactive shell which gets a different path -- at least that frequently stymies people on unix.

Resources