One of the more obvious things lacking from Windows is an ssh (secure shell) client, and this has caused me no end of grief trying to check out code from
Subversion repositories on servers that require ssh access - such as our own.
I'd previously managed to get access by forcing my username in the URL of the repository along with a saved
PuTTY session name:
svn+ssh://alistair@(saved PuTTY session name)/etc...
...where the saved PuTTY session used my imported private key from the live host.
(Note: you *must* use PuTTYGen to convert your OpenSSH keys to PuTTY-compatible keys)This caused a certain amount of sneering from the Debian users in the office, who didn't have to jump through any of these hoops, but I could live with that...
The latest problem to have me gesticulating at the screen like a south-american-footballer-in-front-of-a-referee-who's-reaching-for-his-pocket was the use of
externals.
An external in a Subversion repository is a URL reference to another resource - for instance, in a Java app that requires a certain library to build, you might add an external pointing to the download url of the particular jar file that you need.
All well and good, but you can also add externals pointing to a different location in the
same repository, for instance, to share config files between back end and front end modules.
Now here was the problem - you can't have relative urls in externals, they have to be absolute. This particular external was pointing to a different lcoation in the same repository in the standard URL way, which works fine on UNIX (Debian) clients because they have a native ssh client :
svn+ssh//(host)/(path)
- but there was no way this was going to work on Windows via PuTTY - the only way I'd got svn+ssh:// urls to work previously was via the username@savedsessionname method. Every time I tried to update the working copy, it would get as far as that external, then give me this error message:
svn: Connection closed unexpectedly
So how do you get round this? Enter the cavalry -
Cygwin.
Cygwin is a command shell for Windows that gives you a
Bash-style environment, including....
(drum roll)..... an ssh client!
With this, you can configure SVN (and the rather wonderful
TortoiseSVN) to use this ssh client and - crucially - pass it a command line parameter that tells it to use your private key file for authentication.
If you open your SVN config file in a text editor, (you'll find this in C:\Documents and Settings\
(username)\Application Data\Subversion\config) you'll see instructions on how to configure ssh. You can pretty much ignore it :-) and just use the following line:
ssh = "C:/(cygwin root path)/bin/ssh.exe" -i "C:/(path to your private key)"
...and that's it! It's one of those really simple solutions that took me a couple of minutes to implement, but hours of desk-headbanging frustration to find. You can also use the same command line in TortoiseSVN -> settings -> network -> ssh client.
One other note: make sure that you point ssh.exe at your
openssh-compatible private key. If you've set up your key with PuTTYGen, you can load it in and export an OpenSSH-compatible key from there.