Archive for the ‘SSH’ Category

rsync over ssh

Wednesday, October 21st, 2009

This example show how to rsync files over ssh running the rsync on the destination host:

rsync -avz -e ssh remote_user@remote_host:/remote/dir /local/dir/

in this case you’d have to enter remote_user password. If you are running rsync on a regular basis, create ssh keys with no password and copy public key to the .ssh/authorized_keys file on the remote user you are connecting as on the remote host.

You can also copy multiple files or directories from the destination host:

rsync -avz -e ssh  remote_host:/remote_dir/file1 remote_dir2/file2 /local/dir

Meaning of options used (from rsync man page):

-a, –archive               archive mode; same as -rlptgoD (no -H)

-z, –compress              compress file data during the transfer

-v, –verbose               increase verbosity

-e, –rsh=COMMAND           specify the remote shell to use