Getting Continua to work with a mercurial repository over SSH takes a couple of additional steps.
Step 1.) Install Putty
Download the set of putty tools at http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Install them into a directory on the machine your Continua server is running.
Step 2.) Generate a public/private key
In the putty directory you just installed, look for the executable called PuTTYgen.exe
. Open it and click the Generate
button. You'll need to move the mouse cursor around until the progress bar reaches the end.
Once it's finished, click the Save private key
button, select Yes
when it asks you to save the key without a pass phrase.
Name the file and save it in your chosen directory. I saved mine as C:\private_key.ppk
.
Step 3.) Storing public key on the SSH Server
If your repository resides on a hosting website like codebashq, you'll need to follow their guide on how to add a public key to your repository hosted there.
If your repository is hosted on a machine which you have SSH access to then you will need access to it through a username and password. For machines using OpenSSH or a common variant, the public key you generated above will need to be put in the authorized_keys
file. You can create (or find) that file in the .ssh
directory of the home directory of the user you logged in, eg. /home/username/.ssh/authorized_keys
The public key needs to be in a format recognized by your SSH server. If it's the common ssh server (OpenSSH) that comes with *nix variants then the format you want is what PuTTYgen.exe
outputs in the field "Public key for pasting into OpenSSH authorized_keys file
:"
Paste it into your authorized_keys
file and save it.
Step 4.) Cache key in registry
To check everything worked, log into the SSH server using plink.exe
. You'll need the SSH server's host name and the user you want the Continua server application to log in as. On your Continua server run this command:
plink.exe -ssh -i "path/to/privatekey/privatekey.ppk" user@ssh_server_name
For me, this command is:
C:\putty\plink.exe -ssh -i "C:\private_key.ppk" vinnie@10.0.0.124
You should then see output like this:
Type y
then hit enter. If you were sent to the SSH server's command line then it worked successfully. If you were prompted with a password then something went wrong. This usually means the keys didn't match. Check your authorized_keys
file and make sure the public key is in the right format and matches in private key you specified to the plink command.
Note: If you skip this step or something went wrong, Continua will not work. The next time Continua tries to run a command over SSH, it will be prompted for a password or for caching the key in the registry. Once this happens there's no way for Continua to recover. You will need to kill the plink.exe process running on the Continua server then stop the Continua server.
Step 5.) Configure mercurial.ini to support SSH
The goal of this step is to add a line to your mercurial.ini file. If you know where to locate it, add this line to the [ui]
section:
ssh = "C:\path\to\putty\plink.exe" -ssh -i "C:\path\to\key\private_key.ppk" -agent
For me, mine was:
ssh = "C:\putty\plink.exe" -ssh -i "C:\private_key.ppk" -agent
If you're having trouble locating the correct ini file, here's some pointers.
If you installed mercurial yourself on the Continua server, the file will be in one of these locations:
Current user logged in:
%USERPROFILE%\.hgrc %USERPROFILE%\Mercurial.ini %HOME%\.hgrc %HOME%\Mercurial.ini
All users on the system:
<mercurial-install-dir>\Mercurial.ini <mercurial-install-dir>\hgrc.d\*.rc
If mercurial isn't installed on server it will use the version bundled with Continua:
<ContinuaInstallDir>\Server\hg\mercurial.ini
Default ContinuaInstallDir location: C:\Program Files\VSoft Technologies\ContinuaCI\
Step 6.) Verify everything worked
To check everything worked, use the svn command on the Continua server and query the SSH mercurial repository. Here's the command I used:
hg status -R ssh://vinnie@10.0.0.124//home/vinnie/hg_test
The hg command will report an error along the lines of:
abort: repository 'ssh://vinnie@10.0.0.124//home/vinnie/hg_test' is not local
This actually means it found a remote repository and it has access to it.
Note: If you are prompted for a password then something has gone wrong with the setting up of private/public keys.