2

Unison is a file-synchronization tool that works over ssh. It accepts configurations in profile (.prf) files. I use an alias

unison my-pref.prf && ssh sameuser@sameserver.fr 'cat toto'

Hence I have to type my password twice. Do you know any way to execute a command on the remote host "before" unison closes the ssh session?

Mike Pierce
  • 1,390
  • 1
  • 12
  • 35
Clément
  • 2,358
  • 28
  • 32
  • 1
    What does this have to do with `bash`? – Jdamian Feb 20 '15 at 18:37
  • 1
    Unless `unison` has hooks to do that in its configuration, probably not. You could maybe play with how it calls `ssh` and make it call a script that calls `ssh` and then does something else, but strictly speaking, it would still do the "something else" after the `ssh` connection is already closed (as does your attempt at an alias). Oh, and you could use `ssh-agent` to avoid having to manually provide your password... – twalberg Feb 20 '15 at 19:21

1 Answers1

3

It looks like that you just want to avoid entering your password twice, so you could set up ssh with a public/private keys to avoid typing your password at all.

Then you would just have to evoke ssh with the keyfile that you make:

ssh -i keyfile sameuser@sameserver.fr 'cat toto'

And you would have to add this option to your unison profile (.prf):

sshargs = -i keyfile
Mike Pierce
  • 1,390
  • 1
  • 12
  • 35