I've got a directory called "secure" that I mount on my laptop via sshfs whenever the server is in reach.

While this server is in reach I want to keep it in two-way sync with a directory called "sync".

The "secure" directory is mounted with pam_mount at login and unmounted at logout. I have setup pam_script to create a symbolic link to "sync" when the mount fails and to remove the link on unmount.

In my first attempt was to run unison with pam_script:


#pam_script_ses_open (runs at the start of a session)

home=`eval echo ~$PAM_USER`

if mount|grep "$secure"; then
    echo Synchronizing with server $sync : $secure
    unison "file://$sync" "file://$secure"
    ln -s "$sync" "$secure"

And for end of session:


home=`eval echo ~$userid`

if mount|grep "$secure"; then
        echo Synchronizing with server
        unison "file://$sync" "file://$secure"
        rm "$secure"

Both these scripts run under root.

At logout the two directories synchronize just fine.

At login however I get the following error message:

Synchronizing with server /home/users/user/sync : /home/users/user/secure

Contacting server...

Fatal error: Wrong number of roots: 2 expected, but 4 provided (ssh://user@server/, /home/users/user, file:///home/users/user/secure, file:///home/users/user/sync)

(Maybe you specified roots both on the command line and in the profile?)

I have verified that no ".unison" directory exists in any users home directory and did apt-get purge unison followed by an apt-get install unison.

I am not entirely happy about using unison in this way (even if it did work) because it would only synchronize at login and logout. It would not be a live synchronization.

How can I get sshfs or fstab to start a live synchronization whenever the directory is mounted or if that is not possible, why is unison failing in my current setup?

I am looking for a clean and robust solution.

closed as off-topic by Luis Alvarado Jul 18 '17 at 13:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This describes a problem that can't be reproduced that seemingly went away on its own or was only relevant to a very specific period of time. It's off-topic as it's unlikely to help future readers." – Luis Alvarado
If this question can be reworded to fit the rules in the help center, please edit the question.

  • @LuisAlvarado my setup is described here: help.ubuntu.com/community/SingleSignOn#Shared_Files. It is not very uncommon that people have laptops and would like to sync those mounts for when they are on the move. Somebody has also market it as a favourite. All of this kinda proves you wrong. – d_inevitable Apr 13 '13 at 21:10
  • Hi @d_inevitable can you provide the answer to the question in this site. – Luis Alvarado Apr 13 '13 at 23:50
  • @LuisAlvarado unfortunately I haven't solved that yet. – d_inevitable Apr 14 '13 at 0:01
  • @LuisAlvarado, sorry I have probably caused some confusion. The link ive posted Is not answering the question, but it brings one to a setup in which you mount a remote filesystem at login. My point was that when somebody sets that up on a mobile workstation such as a laptop it desirable to somehow cache that filesystem locally. And this is what I am trying to achieve and this is what the question is about. So it will be useful to anybody who set up the system as described on that link, but has a laptop that is not always online. – d_inevitable Apr 14 '13 at 0:06
  • Well the fact that you took your time to explain this shows you are committed to the question which I wrongly closed. Thanks again for the information and will leave the question opened for anybody to help you in this case (Which also intrigues me). – Luis Alvarado Apr 14 '13 at 0:46

Browse other questions tagged or ask your own question.