How to set up Unison over SSH for file synchronization between Windows XP and Ubuntu
In Windows XP:First, install Unison.
1. download Unison pre-compiled binaries for Windows from
http://alan.petitepomme.net/unison/index.html
no installation is required.
2. Check if there is an GTK folder in the directory C:\Program Files\Common Files\.
If not, download and install GTK+ Rev (Pidgin GTK+, at least version 2.12) from
http://sourceforge.net/projects/pidgin/files/
You also have to add C:\Program Files\Common Files\GTK\2.0\bin
to the system PATH variable in the system settings:
(a) right click "My Computers", select "Properties"
(b) In "Advanced", select "Environment Variables"
(c) In "System variables", select to edit "Path"
(d) Add the new path to Path
Now Unison should work. If you start Unison, you will be asked to
select an existing profile or create a new one. We will talk about
the profile later.
Next, install PuTTY.
1. download Windows installer for everything except PyTTYtel from
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
install PuTTY. Then putty.exe, pageant.exe, puttygen.exe and plink.exe are installed.
2. download a ssh2plink.bat from
http://twiki.org/p/pub/Codev/UnisonKeySetup/ssh2plink.bat
or you can create a batch file named ssh2plink.bat containing following commands:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@echo off
rem fix ssh args to be compatible with plink (putty)
rem Required for Unison synchronisation over ssh.
rem Following options are probably compatible:
rem -l name, -[1246AaCiNstTvVxX]
rem incompatible:
rem -p nnn (replaced by P); -e none (no equivalent)
setlocal
rem Edit this to point to your location for plink.exe
set PLINKEXE=P:\apps\putty\plink
set ARGLIST=-ssh
:nextarg
if "x%1" == "x" goto doneargs
if NOT "%1" == "-p" goto checkesc
rem plink uses upper case P to flag port number
set ARGLIST=%ARGLIST% -P %2
shift
shift
goto nextarg
:checkesc
if NOT "%1" == "-e" goto useit
rem unison likes to include "-e none" which plink does not support.
shift
shift
goto nextarg
:useit
set ARGLIST=%ARGLIST% %1
shift
goto nextarg
endlocal
:doneargs
%PLINKEXE% %ARGLIST%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3. In ssh2plink.bat, change the directory of PLINKEXE to your own directory.
For example, if your plink.exe is under "C:\Program Files\PuTTY", you can modify it to
"set PLINKEXE=P:\Program/ Files\putty\plink".
Note that if there is any space in the directory, you have to use "/ " instead of " ".
4. put the ssh2plink.bat in the same folder with the Unison execution file.
Third, edit the profile in Unison.
1. Find the directory of the default profile: default.prf.
Typically it locates in "Documents and Settings\username\.unison"
2. create a new profile, say, music.prf containing
sshcmd = ssh2plink.bat
root = C:\music
root = ssh://UsernameonUbuntu@ipaddress/home/music
sshargs=-pw password
In the above, the second line is the local directory that you want to synchronize.
The third line is the second directory you want to synchronize on your Ubuntu machine
with its ip address and your login name.
The last line is the password corresponding to the usernameonubuntu on Ubuntu.
We are done with Windows.
In Ubuntu:
1. Install Unison and openSSH server for Ubuntu.
You can install them by using Ubuntu's package manager.
2. Start SSH server on Ubuntu by command:
Sudo /etc/init.d/ssh start
Now you can run your Unison on your Windows machine. It shoud work!
