Sunday, June 8, 2008

rsync Over ssh

I love the rsync command. A great tool for grabbing a copy of files you need from one location. If the server is remote, you probably want to make sure you are transferring these files securely. For this we are going to use rsync in conjunction with ssh. One thing to note, in order to do this you will need to set up ssh between the two servers to use keys.

Here is a simple rsync+ssh example:

rsync -ave ssh username@www.remoteserver.com:/location/on/remote/server/ /location/on/local/machine/


Here is how the command breaks down:

rsync (Start of the command)
-a (archive mode)
v (verbose, will show you what is being copied as it is being copied)
e
(specify the remote shell to use)
ssh (how to connect to remote server)
username (username to connect as)
@www.remoteserver.com (remote server to connect to)
:/location/on/remote/server/ (location on remote machine of file(s) you want to copy)
/location/on/local/machine/ (location of location machine where you want to copy the files to)


A lot more can be done using rsync. For more ideas please run 'man rsync' on you local Linux box.

No comments: