Mercurial“hg克隆”在 Windows 上通过 ssh 并出现 plink 问题

发布于 2024-08-31 12:20:14 字数 2283 浏览 7 评论 0原文

我有一台 Windows Server 2008 计算机 (iis7),上面设置了 CopSSH。为了连接到它,我有一台安装了 Mercurial 1.5.1(和 TortoiseHg)的 Windows 7 计算机。

我可以使用 PuTTY 通过非标准 ssh 端口和 .ppk 文件连接到服务器。所以我知道服务器可以通过 SSH 连接。

接下来,我想使用 CLI 通过 hg clone 连接来获取私有存储库。我在其他地方看到你需要在 Mercurial.ini 文件中配置 ssh,所以我的 Mercurial.ini 有一行: ssh = plink.exe -ssh -C -l username -P #### -我“C:/Program Files/PuTTY/Key Files/KyleKey.ppk”
注:
username 填写我通过 copSSH 设置的用户名。
#### 填写了我为 copSSH 定义的非标准 ssh 端口。

我尝试执行命令 hg clone ssh://inthom.com 但收到此错误:
远程:bash:inthom.com:找不到命令
中止:没有来自远程 hg 的合适响应!

看起来 hg 或 plink 解析主机名,使其认为 inthom.com 是一个命令,而不是 ssh 到的服务器。这真的很奇怪。

接下来,我尝试仅使用 plink 通过 plink -P #### ssh://inthom.com 进行连接,然后系统会提示我输入用户名和下一个密码。我输入它们,然后出现此错误:
bash: ssh://inthom.com: 没有这样的文件或目录

所以现在看来​​ plink 无法正确解析主机名。

我摆弄了一段时间,试图弄清楚如何使用空的 ssh:// 字段调用 hg clone,最终发现这个命令允许我访问服务器并在 inthom.com 服务器上克隆一个测试存储库:< br> hg clone ssh://!/Repos/test

! 是我发现的字符,让我将主机名留空,但指定要克隆的存储库文件夹。

我真正不明白的是 plink 如何知道要 ssh 到哪个服务器。我的 Mercurial.ini 和命令都没有指定服务器。我见过的 hg clone 示例都没有 ! 字符。它们都使用一个地址,这是有意义的,因此您可以通过 ssh 连接到您想要克隆的任何存储库。

我唯一的猜测是,它以某种方式默认为我使用 PuTTY 进行 SSH 访问的最后一个服务器,但我通过 SSH 连接到另一台服务器,然后尝试使用 plink 访问它,但 plink 仍然默认为 inthom.com(已通过plink 的 -v arg)。所以我完全不知道 plink 如何获取这个服务器的值。

为了“好玩”,我尝试使用 TortoiseHg,并且只能在使用 ssh://!/Repos/test 作为源时克隆存储库。

现在,您可以看到,由于 plink 无法正确解析主机名,因此我必须在 Mercurial.ini 文件中指定端口号和用户名,而不是像 [电子邮件受保护]:#### 就像您所期望的那样。一开始试图弄清楚这一点让我发疯,因为我会收到无法联系到主机的错误,但我知道情况不应该如此。

我的问题是如何配置我的设置,以便 ssh://[email protected]< /a>:####/Repos/test 是否正确解析为要复制的用户名、主机名、端口号和存储库?是我使用的 plink 版本有问题,还是我搞砸了某些设置?如果是 plink 的错,我可以使用其他工具吗?

我将尝试让我的朋友设置连接到同一个存储库,因此我希望有一个干净的解决方案而不是这个 ! 业务。特别是当我不知道 plink 如何获取这个默认服务器时,所以我不确定他是否能够正确访问 inthom.com。

附言。我必须使用大量不同的教程才能到达这个阶段。因此,我还没有尝试将任何更改推送到服务器。希望我能解决这个问题,然后我可以尝试将更改推送到存储库。

I have a Windows Server 2008 machine (iis7) that has CopSSH set up on it. To connect to it, I have a Windows 7 machine with Mercurial 1.5.1 (and TortoiseHg) installed.

I can connect to the server using PuTTY with a non-standard ssh port and a .ppk file just fine. So I know the server can be SSH'd into.

Next, I wanted to use the CLI to connect via hg clone to get a private repo. I've seen elsewhere that you need to have ssh configured in your mercurial.ini file, so my mercurial.ini has a line: ssh = plink.exe -ssh -C -l username -P #### -i "C:/Program Files/PuTTY/Key Files/KyleKey.ppk"
Note:
username is filled in with the username I set up via copSSH.
#### is filled in with the non-standard ssh port I've defined for copSSH.

I try to do the command hg clone ssh://inthom.com but I get this error:
remote: bash: inthom.com: command not found
abort: no suitable response from remote hg!

It looks like hg or plink parses the hostname such that it thinks that inthom.com is a command instead of the server to ssh to. That's really odd.

Next, I tried to just use plink to connect by plink -P #### ssh://inthom.com, and I am then prompted for my username, and next password. I enter them both and then I get this error:
bash: ssh://inthom.com: No such file or directory

So now it looks like plink doesn't parse the hostname correctly.

I fiddled around for a while trying to figure out how to do call hg clone with an empty ssh:// field and eventually figured out that this command allows me to reach the server and clone a test repo on the inthom.com server:
hg clone ssh://!/Repos/test

! is the character I've found that let's me leave the hostname blank, but specify the repo folder to clone.

What I really don't understand is how plink knows what server to ssh to at all. neither my mercurial.ini nor the command specify a server. None of the hg clone examples I've seen have a ! character. They all use an address, which makes sense, so you can connect to any repo via ssh that you want to clone.

My only guess is that it somehow defaults to the last server I used PuTTY to SSH to, but I SSH'd into another server, and then tried to use plink to get to it, but plink still defaults to inthom.com (verified with the -v arg to plink). So I am at a loss as to how plink gets this server value at all.

For "fun", I tried using TortoiseHg and can only clone a repo when I use ssh://!/Repos/test as the Source.

Now, you can see that, since plink doesn't parse the hostname correctly, I had to specify the port number and username in the mercurial.ini file, instead of in the hostname like [email protected]:#### like you'd expect to. Trying to figure this out at first drove me insane, because I would get errors that the host couldn't be reached, which I knew shouldn't be the case.

My question is how can I configure my setup so that ssh://[email protected]:####/Repos/test is parsed correctly as the username, hostname, port number, and repo to copy? Is it something wrong with the version of plink that I'm using, or is there some setting I may have messed up? If it is plink's fault, is there an alternative tool I can use?

I'm going to try to get my friend set up to connect to this same repo, so I'd like to have a clean solution instead of this ! business. Especially when I have no idea how plink gets this default server, so I'm not sure if he'd even be able to get to inthom.com correctly.

PS. I've had to use a ton of different tutorials to even get to this stage. Therefore, I haven't tried pushing any changes to the server yet. Hopefully I'll get this figured out and then I can try pushing changes to the repo.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

挽袖吟 2024-09-07 12:20:14

我知道我迟到了,但现在总比永远迟到要好。
好的,那么...连接 Mercurial SSH 的命令

ssh = plink.exe -ssh -C -l 用户名 -P #### -i "C:/Program Files/PuTTY/Key Files/KyleKey.ppk"

完全没问题,但问题出在 Plink 上。

Plink 在处理名称中包含空格的文件夹时存在问题。所以,问题就出在

“C:/Program Files/PuTTY/Key Files/KyleKey.ppk”

您有两个选择:

  1. 您可以将此“KyleKey.ppk”文件移动到名称中不包含空格的路径中。例如,您可以将此文件移动到“C:\”或“D:\Path\Without\Space\In\Name”中。

  2. 您可以使用 Windows 短路径名。例如,我有

    <块引用>

    ssh = "C:\Progra~2\Plink\Plink.exe" -ssh -i "C:\Progra~2\PuTTYgen\hrle.ppk"

    在我的“Mercurial.ini”中。

    “C:\Progra~2”是“C:\Program Files (x86)”。

如果 SSH 私钥受密码保护,Plink 将挂起。

而且,在将 Plink 与 TortoiseHg 或 MercurialEclipse 等其他 GUI 工具结合使用之前,您必须添加此服务器以了解服务器列表。如果你不这样做,Plink 将挂起等待你的响应,但你无法给出响应,因为你使用 TortoiseHg 而不是在命令行上。有关此主题的更多信息,请参阅 AccessingSshRepositoriesFromWindows

I know I am late but better now then never.
OK, so... Command for connecting to Mercurial SSH

ssh = plink.exe -ssh -C -l username -P #### -i "C:/Program Files/PuTTY/Key Files/KyleKey.ppk"

is perfectly OK, but the problem is with Plink.

Plink have problems with folders that have spaces in their names. So, the problem is in

"C:/Program Files/PuTTY/Key Files/KyleKey.ppk"

You have two options:

  1. You can move this "KyleKey.ppk" file into a path with no spaces in name. For example, you can move this file in "C:\" or "D:\Path\Without\Space\In\Name".

  2. You can use Windows short path names. For example, I have

    ssh = "C:\Progra~2\Plink\Plink.exe" -ssh -i "C:\Progra~2\PuTTYgen\hrle.ppk"

    in my "Mercurial.ini".

    "C:\Progra~2" is "C:\Program Files (x86)".

Plink will hang if SSH private key is protected with a password.

And also, you must add this server to know server list before you even use Plink in conjunction with TortoiseHg or some other GUI tool like MercurialEclipse. If you fail to do that Plink will hang waiting for you response which you can not give because you work with TortoiseHg and not on the command line. More on this subjet in AccessingSshRepositoriesFromWindows.

魔法少女 2024-09-07 12:20:14

使用 plink,您不需要使用 ssh:// 协议标识符。您只需使用 {user}@{host}:{path} 格式即可正常工作。

例子:

plink -ssh -C -l {用户名} -pw {密码} -P 22 -i "C:/Program Files/PuTTY/Key Files/KyleKey.ppk" inthom.com:/Repos/test

将 {用户名} 替换为user 和 {pass} 以及密码。

With plink you do not need to use the ssh:// protocol identifier. You can simply use {user}@{host}:{path} format and it will work fine.

Example:

plink -ssh -C -l {username} -pw {pass} -P 22 -i "C:/Program Files/PuTTY/Key Files/KyleKey.ppk" inthom.com:/Repos/test

replace {username} with the user and {pass} with the password as well.

清风不识月 2024-09-07 12:20:14

哟,我也有同样的问题。我的设置的问题在于 plink 使用的是 putty 中设置的默认服务器,而不是我提供的服务器。我必须打开腻子并删除默认服务器,然后保存。尝试在没有服务器的情况下使用 plink..如果您的命令通过,则您有一个默认服务器..

yo, i had the same problem. What was wrong with my setup is that plink was using the default server set in putty instead of the one I was providing. I had to open putty and remove the default server and then save. Try to use plink without a server.. if your command passes, you have a default server..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文