简体   繁体   English

在Windows上的ssh客户端和服务器上的Mercurial

[英]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). 我正在尝试将Mercurial配置为与Windows服务器(freeSSHd)和客户端(包括命令行和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. 使用公钥验证,我已经能够连接到服务器,我能够使用plink执行“hg版本”并获得响应,但是当我尝试从ssh服务器克隆存储库时,命令似乎挂。 Running with -v yields: 使用-v运行产生:

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. 直接在服务器上运行hg serve命令会产生一个明显响应的Mercurial服务器,但客户端似乎没有进一步的请求。

Running "hg serve" in the repository directory and cloning over http works perfectly. 在存储库目录中运行“hg serve”并通过http克隆工作完美。

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? 是否有客户端(hg和TortoiseHG)没有发送以继续请求流?

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. 附加信息:如果我更改为目标计算机上的无效存储库,则会显示相应的错误,因此看起来远程hg正在运行并正确评估路径。

Running with --debug and --traceback results in: 使用--debug和--traceback运行会导致:

sending hello command
sending between command

It hangs here, until I CTRL-C 它挂在这里,直到我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. 回应Ryan:服务器上似乎没有任何CPU使用或增加内存使用量。 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. 11/19/2009:更多信息:问题肯定在freeSSHd / server方面。 Connecting to bitbucket over ssh with the same keyset works fine. 使用相同的键集通过ssh连接到bitbucket工作正常。 Still working on this. 仍在努力。

The solution that worked for me was disable the "Use new console engine" option which is inside the SSH tab. 对我有用的解决方案是禁用SSH选项卡内的“使用新控制台引擎”选项。 Another thing is the path. 另一件事是路径。 ssh://ssh_user@SSH_Server_Address:SSH_Port/Win_Drive_Letter:/Path_To_HG_Repository 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 SSH://programmer@192.168.1.150:5522 / d:/存储库/ MyProyect /中继线

I currently use MercurialHG not the CLI. 我目前使用MercurialHG而不是CLI。 I hope that this help 我希望这有帮助

JQ 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". 我刚才有同样的症状,虽然在Ctrl + C之后hg有点帮助 - 显然plink正在等我说y / n“将服务器保存到缓存”。 Unfortunately hg couldn't pass my y/n to it interactively (nor tell me that plink printed something important...) 不幸的是,hg无法以交互方式将我的y / n传递给它(也没有告诉我plink打印的东西很重要......)

Solution: 解:

  1. plink to the host once and save server info to cache plink到主机一次,并将服务器信息保存到缓存
  2. add -batch to the plink command line so that next time this happens it aborts instead. -batch添加到plink命令行,以便下次发生这种情况时会中止。

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 ): .hgrc文件的完整示例(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. 另一个选择是尝试Cygwin版本的hg和ssh。 You can log SSH problems in that version with the -e option; 您可以使用-e选项记录该版本中的SSH问题; for instance, hg clone -e 'ssh -vvv' ssh://you@server/repo... 例如,hg clone -e'ssh -vvv'ssh://你@ 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. 我在我的实时网站mysite.com上有一个存储库我在我的本地机器上有一个本地存储库,在mysite.com文件夹中我有其他存储库,所以我将[ui]设置添加到每个存储库文件夹中的/.hg/.hgrc文件中在我的本地计算机上而不是Mercurial.ini文件。

First, if you have already connected via Putty, save the session because Plink can use stored sessions. 首先,如果您已经通过Putty连接,请保存会话,因为Plink可以使用存储的会话。 Use Pageant and add your key. 使用Pageant并添加密钥。 Try running plink from the command line to connect using the stored session. 尝试从命令行运行plink以使用存储的会话进行连接。 For example, I saved my session as "mysite" in Putty. 例如,我在Putty中将我的会话保存为“mysite”。

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 如果这样做,请在.hgrc文件中尝试以下操作

[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. Plink设置在我的PATH中,由于mysite会话已存储在Putty中,因此它知道要查找的内容。

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. 编辑:对不起,你来不及使用tortoiseHG而不是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. 也许是'hg'不在路径中的情况。 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. 您可以从命令行中看到正在调用'hg'作为'hg'运行,这意味着它必须位于服务器的路径中。 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). 尝试使用--remotecmd选项进行克隆,以提供服务器上 hg可执行文件的完整路径(祝你好运Windows引用正确)。

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. 您的plink hg version测试可能会起作用,因为它是作为交互式shell启动的,它获得了不同的路径 - 至少经常阻碍unix上的人们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM