Installing Unison on Windows

NOTE: there are two ways to sync files using Unison; through mounted drives and via ssh. To use ssh, you need to install an ssh client (windows doesn't have one by default), and I chose Cygwin for this. While Cygwin is a little overkill (it is a full blown replication of Unix utilities on Windows), it just seemed more natural. However, there are ways of getting the ssh working using standard Windows programs like PuTTY.

If you do not need ssh connectivity (you will only sync mounted drives), you do not need to do any of the steps involving Cygwin below. The downside to this is that you will not benefit from the compression and client/server relationships that are available on a remote Unix system when doing this. Also note that, on the remote system, you must have Unison installed for the ssh sync.

Also, if you are comfortable doing all the configuration and execution from the comnand line (no gui), use the Unison-2.32.52 Text instead of the Gtk+ version. In the simplest implementation, you can install that, and no ssh client (and no gtk library), though you will have to manually build the unison configuration file.

Download the following:

Install Cygwin (Linux utilities for Windows)

  • Create a folder someplace. You can delete the folder when you're done OR, if you want to add/remove or update stuff in the future, put it someplace that you can keep. I generally just put it in My Documents\Downloads.
  • Move Setup.exe into it and execute by double clicking.
  • Take Defaults for first few pages
  • For Choose A Download Site, just choose something; it makes no difference, though if you can find something close to you, use that.
  • On the screen for Select Packages, go to Net | openssh and mark it for inclusion (click on Skip one time, leave binary checked). You will also need an editor of some type, and I usually choose joe. If you keep this directory, you can rapidly add/remove packages in the future by clicking on setup again
  • Click Next, then when it comes to the screen Resolving Dependencies, click Next to begin the download and installation. Note that initial installation can take some time as this is similar to a barebones Linux install.
  • After installation, choose whether you want an icon on the desktop or not. If this is for a user, generally uncheck that box.
  • Open the Cygwin termainal for the user
  • run command env | grep -i home to see where your home directory is (hint, you can change this as an environmental varible in Windows)
  • IF YOU HAVE a public/private key, create the folder ~/.ssh, and put the key files in there
  • IF YOU DO NOT HAVE a public/private key, generate one by running the command 'ssh-keygen -t rsa -b 4096'. Accept defaults EXCEPT when asked for a password. If you put in no password, Unison will run without the user having to enter it every time, but that means this is fully dependant on Windows security. Your choice on that.
  • Create a file ~USERNAME/.ssh/config with the following information:
host ALIAS
  •  Copy the newly created public key to the remote server, however you can do that. The files are in C:\cygwin\home\USERNAME\.ssh where USERNAME is the users username on the computer. Add the public key into ~SHARE/.ssh/authorized_keys, where SHARE is the share you are connecting to.
  • Initialize the known_hosts file for the user by typing in the command: 'ssh trillian'. You will get a message that the server is not known, and you should type "yes" to have it put in the known_hosts file. If you are asked for a password, it means you messed up on the connection. The ssh terminal will NOT show anything when successful, and you must break out of it with ^C
  • You are done configuring cygwin, so close the window.

Install gtk-win (GTK+ Windowing for Windows)
First, you MUST have your screen in 32 bit mode. This will not work in 16bit, so if you're remoted in, be sure to accept the slower speed.

  • begin the install (double click on the download). We will take all defaults, but I'm including what they are below
    • All you need are the GTK libraries.
    • When asked, agree to set up the PATH environmental variable. VERY IMPORTANT
    • Select Install.
    • Finish the install.

Install Unison

  • open the Unison zip file. Copy the executable that says Gtk+ (ie, Unison-2.32.52 Gtk+) on it to the desktop (or wherever you want to store it, then create a link to it). It must not be in the zip file, however.
  • Unison needs to know where the ssh command is, edit your environmental variables
    • Right click "My Computer" and select Properties
    • Find the tab that has an Environment Button, and click that.
    • Add c:\cygwin\bin to PATH variable (separate with a semi-colon). I usually do this under the individual users environment instead of globally.
  • Configure Unison
  • Double click on Unison. This DOES NOT work under Remote Desktop. You will need either physical access, or VNC.
  • Double click on Default Profile
  • For source, select someplace on your local machine (like My Documents)
  • For target, select SSH
    • Enter the relative directory in the remote connection, ie /Storage/MyFiles or /Storage/Laptop. This does NOT have to be the same final directory name as the source.
    • Put in the hostname, from the line you created in the config directory


If you are attempting to sync with a Unix server running the scponly shell, you will need to do the following on the remote server for Unison to work. Remember, the following is on the remote Linux scponly server

  • Ensure the Unison binary and all libraries are installed. For newer versions of scponly, this is a built in option.
  • You will need to create a chrooted home for the user, since scponly is using a chroot and that users HOME variable is incorrectly set. Assuming a user named USER, who's "real" home directory is /home/scpdrives (on the remote server), do the following as root.
mkdir -p ~USER/home/scpdrives/USER
chown ROOT:ROOT ~ROOT/home/scpdrives/ROOT/

You are basically replicating the /home directory structure within the chroot'd jail.

If you need to exclude/include directories/files in your sync, look at the following description.

Last update:
2012-08-10 23:45
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.