2009/05/19

Unison on Windows

Since we are moving from one place to another (still in Rome), i needed to sinchronyze files between my current linux workstation and the notebook I was given. For me, the obvious tool is unison, and I went looking for instructions to make it work on windows, as on the notebook it's installed a windows-only VPN software.

The process turned to be fairly complex, as usual due to dll/path hell which is the doom of windows machines when dealing with a no-installer software.

1. Getting Unison and prerequisites.
The unison Homepage points here: , where I downloaded the gtk-enabled windows executable.
Unison needs the gtk library, the page suggests using those provided by Pidgin. I already had Pidgin installed, so I did nothing.


2. Putting Unison where it would find gtk dll
The page also advise to append the gtk library directory to the %PATH% variable. I opted instead to move the Unison-2.27.57 Gtk+.exe executable in the GTK directory ("C:\Programmi\File comuni\GTK\2.0\bin" in my system). This is more straightforward and easier to do and lets me have more than one GTK installation if need arises. Note that you cannot register the dll to be automatically found (I don't know why, but a dialog tells me so when I use regsvr32 on libgtk-win32-2.0-0.dll.


3. Getting ssh.exe plink wrapper

From this page [http://www.wischik.com/lu/programmer/unison-ssh.html] I downloaded the plink wrapper (I googled for unison windows ssh and it was the first hit). I put in the same folder that the unison executable. It has a bug and it does not work with a plain password (I planned to use a private key anyway)


4. Generating private key to use with plink

It's easy, use puttygen (you should have it if you installed putty with the standard windows installer, otherwise grab it here). Note that the Putty links points to the most current version of Putty, but it may change, so peek at the download page for updates.
As usual, generate a new key (I prefer to generate a fresh key for automated task, it's easier to revoke if it gets compromised as it does not have usually a passphrase) and publish the public key on the linux box which will act as a "unison server" in the authorized_keys file (usually ~/.ssh/authorized_keys, change the permissions to rw------- before doing anything else if you create a new file)


5. Configuring the key in the unison profile

Using the ssh plink wrapper, you need to modify the unison profile file. Create a new profile, select the local directory to configure, select the remote directory (using ssh), insert the host and the user that you granted access by publishing the public key.
Then locate the profile file (in C:\Documents and Settings\\.unison on my windows system) and add these lines:

sshcmd=ssh.exe
sshargs=-i path\to\privatekey_file_on_windows.ppk
ignorecase=true

you can add also perms=0 since most of the times the permissions will be totally screwed from a unix fs to ntfs (god forbids using FAT32 nowadays!)
Note: the path you specify with the sshargs option must not contain spaces.


6. Run and test

Now run Unison and verify that it detects differences in the files and that it makes good suggestions on which file is newer on which system.

Troubleshooting
The only thing you can do wrong is the public key stuff, check with cmd, cd to the directory where you have copied ssh.exe and try ssh manually:

C:\somedir> ssh -l username -i path\to\privatekey_file_on_windows.ppk hostname

and see if you can login.
Otherwise you screwed something up; check the authorized_keys name, permissions and position on the filesystem (and if it contains the right public key).

No comments:

Post a Comment