Mission: to get rsync going over ssh. This will allow me to synchronise files on local client and remote server. Rsync is a nice fast incremental copy program designed for synchronising file sets between a client and server. The result is that both computers share identical versions of a set of files.
Steps:
- install openssh on client and server
- install rsync on client and server
-
to avoid typing in passwords, create ssh key using:
ssh-keygen -t dsa
- Log into server using sftp
-
copy /home/
/.ssh/id_dsa.pub to the server - on the server, merge contents of id_dsa.pub with ~/.ssh/authorized_keys2
- From client, try logging in using ssh or sftp. Key should be accepted.
- Start rsyncing.
Note: using a blank passphrase for ssh means you will not be prompted for a passphrase when you log in but this is a security risk: if anyone gets their hands on the key file they can get it.
Examples: Copy files in the directory 'logs' to the directory 'blah' on server ad-pc (files will be in blah/*).
rsync -avz logs/ -e ssh ad-pc:blah/
Copy the files back.
rsync -avz -e ssh ad-pc:blah/ logs/
Copy the directory 'logs' and files in it to the directory 'blah' on server ad-pc (files will be in blah/logs/*).
rsync -avz logs -e ssh ad-pc:blah/
Copy the directory 'logs' and files in it to the directory 'blah' on server ad-pc. Copy recursively and delete files on the receiver that do not exist on the sender (i.e. replicate deletion of files).
rsync -avzr --delete logs -e ssh ad-pc:blah/
Copy while logging in as a different user.
rsync -avz -e ssh <user>@ad-pc:www/modules/ modules/
Note the subtle use of the trailing /.
- blah/
-
copy files to/from directory
- blah
-
copy directory
itself
Using cygwin on Windows 2000 I had a problem copying from the server to the local pc: the shell would hang real hard at the end of the transfer. I tried reinstalling the cygwin stuff from a different server (mirror.ac.uk) and found a much more recent version (2.6.2 as opposed to 2.5.5). This fixed the problem, which may have been this.

