Configuring Unison on Windows

Unison is a free file sync utility that runs on Windows, OS X, or Linux. As with most of these things, Windows support is a bit of an afterthought, and can be tricky to work with. Here’s a step-by-step list of what I did to get it working. Note that I’m only setting things up for mirroring (ie one-way sync) so I only installed the SSH server and Unison text client on the “client” and the remainder of the stuff on the “server.” If you’re doing full 2-way sync, perform all the installations on both machines.

  1. Install GTK for Windows. I tried a couple of installers that didn’t work, but found an installer as part of this project that worked great.
  2. Install an SSH server. freeSSHd is a great little program, and it’s a tiny download. Make sure to install as a Windows service when it asks you.
  3. Configure the SSH server. Starting up the freeSSHd GUI actually tries to open another SSH server, even though you configured one to run as a service. This means that changes you make in the GUI won’t take effect until you restart the service. The only thing you’ll need to do is create a user, with password stored as SHA1 hash, that is allowed to use the shell.
  4. Configure environment variables. Unison expects to find an environment variable called HOME and will complain if it doesn’t find it. I set mine to C: and it’s happy with that.
  5. Get a fake SSH client. Unison expects that it can say ssh and something will answer. So first download PuTTY and Plink and make sure they’re in your path. Then download the Unison-ssh wrapper and make sure it’s in your path. It will redirect any calls for ssh.exe to plink.exe
  6. Put the Unison client in place. Windows binaries are available here. Rename the binaries something simple like unison-gui and unison. I suggest naming the text version unison as this is the name that Unison expects the client to have. Make sure the binaries are also in your path.
  7. Test your SSH. At this point you should be able to go to a command prompt and do this:
    ssh -l username -pw password server "unison -version"
    and get something like this:
    unison version 2.27.57
  8. Test your Unison. Assuming that worked, try testing Unison with the -testserver parameter:
    unison -testserver -sshargs "-l username -pw password" c: ssh://server//
    which should give you something like this:
    Connected [//server1/c:/ -> //server2/c:/]
  9. Set up your files. Congratulations, the servers are talking to each other! I suggest running the next step in the GUI, as there may be a lot of initial file syncing to be done:
    unison-gui -sshargs "-l username -pw password" c:directory ssh://server//directory
    It’s pretty self-explanatory, arrows point in the direction of updates, click “Go” when you’ve got it set up how you want it.

After the initial setup, you can continue using the GUI, or start using the text mode. There are a number of preferences that make things easier, which you can learn about in the documentation. As I mentioned, I’m using this for mirroring, so I use the -force parameter to make sure the “server” always takes priority over the “client.”