This isn’t necessarily the best way to use rsync… but here is a fairly simple (uneducated) way of getting two-way communication going between a source and backup host.
Steps:
- Generate keys on source-host:
ssh-keygen -t rsa
(orssh-keygen -t dsa
) - Copy source-host public key to backup-host using
ssh-copy-id
1:ssh-copy-id -i id_rsa.pub backup-user@backup-host
- Generate keys on backup-host:
ssh-keygen -t rsa
- Copy backup-host public key to source-host using
ssh-copy-id
:ssh-copy-id -i id_rsa.pub source-user@source-host
- Make sure
ssh-agent
is installed and running on backup-host.2 - Use
ssh-add
to add key tossh-agent
on backup-host3. - Finally, run rsync on backup-host:
rsync -avz -e ssh source-user@source-host:/path/for/backup/source backup_to_here
Notes:
- From this article. (I ended up making these keys for the opposite servers… for example: creating public key on source server is actually meant to be put into backup server authorized_keys file… and creating public key on backup server is actually meant to be put into source server authorized_keys file.)
- From
ssh-agent
article. (source) - If
ssh-add
doesn’t seem to work, try running this in the shell:eval `ssh-agent`
. (source) - On Mac OS X, I seemed to have to run rsync in a new session before I got the pop-up dialog box asking if I’d like to remember this ssh passphrase in the Keychain Access utility.
See Also: