I have a Linux VPS account which I use for hosting this and some private photo collections [i.e. personal, not porn!] etc, I used to use Unison to sync my photo directories between my Linux VPS and my Linux Laptop. I’m currently running Windows XP on my laptop, so I was looking for a way of syncing stuff with my off site storage again, after some playing around with different versions of Unison, I settled on running unison from withing Cygwin. I have a bash script that fixes the permissions on the remote filesystem and some other stuff using SSH. Getting ssh-agent to work cleanly in a Cygwin environment is tricky, I found the following tips, and liked this one. It needed some tweaking to work, probably just the knock on effect of having spaces in my $HOME.

This fragment can be used to setup the ssh-agent so that the rest of the commands in the script that use SSH don’t prompt for passphrases (including running unison using ssh)

[quickcode:noclick]

#

# Setup ssh-agent if it’s not already there

# This is where the ssh-agent environment settings are stored for scripts

# using this fragment

SSH_ENV=”$HOME/.ssh/environment”

function start_agent {

echo “Initialising new SSH agent…”

/usr/bin/ssh-agent | sed ‘s/^echo/#echo/’ > “${SSH_ENV}”

echo succeeded

chmod 600 “${SSH_ENV}”

. “${SSH_ENV}” > /dev/null

/usr/bin/ssh-add;

}

# Source SSH settings, if they are there

if [ -f “${SSH_ENV}” ]; then

. “${SSH_ENV}” > /dev/null

# If ssh-agent is dead or gone, start from scratch

ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || {

start_agent;

}

else

# start from scratch

start_agent;

fi

[/quickcode]

After this script, I just call ssh a couple of times to tidy up the remote destination, and then call unison using a profile that also uses ssh, slicker than a greased monkey falling of a pole.