views:

926

answers:

3

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.

A: 

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.

Sean Madden
A: 

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

A: 

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.

hrle