views:

2317

answers:

7

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.

A: 

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.

Ry4an
By changing to an invalid repository path, I can get an error so I'm fairly certain that hg is being invoked properly and is in the path. Above I've also provided output from --debug and --traceback.
Ben Von Handorf
Yeah, sounds right. I'll delete this answer once someone figures it out.
Ry4an
A: 

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:

  1. plink to the host once and save server info to cache
  2. 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
romkyns
For me, -batch didn't resolve the issue. I had managed to get the certs into the cache previously. I need to find more time to dig into this, but it looks like hg just isn't issuing the commands from the client to start doing work.
Ben Von Handorf
+1  A: 

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...

A: 

I have the same problem...

AB
+1  A: 

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

Rob
A: 

Hi Ben,

just wondering if you got the scenario as per above working? going through the same torture. could you please point me the right direction if you got it sorted?

thank you in advance

krajicek
You should post this as a comment on the question, not an answer.
Gili
A: 

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
Eeyore