0

I have setup a Pi with ArchLinux. Now I want to sync one directory called Pi on my local machine with the directory Pi on my Pi.

At first I have written a little script that uses rsync but I've run into some problems as it is not bi-directional and couldn't create a parent directory.

Then I saw a post that mentioned unison. At this time I have this command:

unison /home/user/Pi/ ssh://ente@192.123.145.78:22//home/ente/Pi/

This works quite nicely. But I always have to type in my password and then what I want to. How can I make unison authenticate me with my RSA key I have generated for ssh?

I login via ssh with that key and rsync also did it. And how can I skip Unison's question what it should do?

unison /home/user/Cloud/Encrypted/ \
    ssh://ente@192.168.178.21:22//home/ente/Cloud << EOF
MYPASSW
g
EOF

Is probably not such a good idea?

  • A simpler approach is to use Syncthing. There is an ARMv6 PKGBUILD in the AUR... – jasonwryan Sep 26 '14 at 0:14
4

The same way as you would setup a password-less ssh connection.

From the machine you're starting unison:

 $ cd ~/.ssh
 $ ssh-keygen

Do not set a password for the key itself when issuing ssh-keygen. Otherwise you'll be asked for it. Now copy the key to the other machine

 scp ~/.ssh/id_rsa.pub ente@192.168.178.21:/home/ente/.ssh/authorized_keys2

or

 ssh-copy-id -i ~/.ssh/id_rsa.pub ente@192.168.178.21

Also, you could use sshfs to mount directory.

If you named your key differently, you need to tell unison about it:

  unison -sshargs="-i ~/.ssh/me"  [other unison options]
  • I have done this already but I have choosen another name, how can I tell unison which identifier file to choose? I have named my key me, so 'me' and 'me.pub'. – Greeneco Sep 25 '14 at 14:28
  • you can use config file from .ssh directory: Host 192.168.178.21 ForwardX11 no ForwardX11Trusted no Port 22 IdentityFile ~/.ssh/me – Scyld de Fraud Sep 25 '14 at 14:32
  • sshargs is listed in the unison help menu as:"sshargs xxx other arguments (if any) for remote shell command" but when using it I get the error "unison: unknown option `--sshargs'" – Greeneco Sep 25 '14 at 14:36
  • sorry, this was a typo on my side: use only a single dash, i.e. -sshargs=-i ~/.ssh/me – Sebastian Sep 25 '14 at 14:37
  • 1
    weird. it seems to think that the path you're providing to ssh is a unison profile. Try to wrap this into quotes -sshargs="-i ~/.ssh/me" – Sebastian Sep 25 '14 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.