ssh & rsync equivalence?

Wayne Davison wayned at samba.org
Sun Mar 29 23:52:53 GMT 2009


On Sun, Mar 29, 2009 at 05:15:58PM +1300, Morgan Read wrote:
> ssh [...] sudo rsync [...] -e 'ssh -i /home/rsync/.ssh/id_dsa' [...]

Those quotes won't survive the trip through that many programs, so
you're undoubtedly ending up with rsync seeing just the "-e ssh" option,
and the -i and beyond are taken as options/args to rsync itself.

Your best bet is to put ssh config items into your /root/.ssh/config
file.  For instance:

Host 192.168.1.100
    User root
    IdentityFile /home/rsync/.ssh/id_dsa

That sets those settings as the default when accessing that IP.

Or give it a name and use that name instead of a hostname or IP when
telling rsync what host to contact.  For instance, in the local host's
.ssh/config file:

Host r40
    Host 192.168.1.40
    User rsync

Then on the remote host:

Host r100
    Host 192.168.1.100
    User root
    IdentityFile /home/rsync/.ssh/id_dsa

Then run this (trailing slash added to avoid /path/etc/etc):

ssh -t r40 sudo rsync -avzAXHn --delete-after /etc/ r100:/path/etc

Your other option is to create a script that executes ssh with the
option(s) you want to use and run that script via rsync's -e option.

..wayne..


More information about the rsync mailing list