Rsync is a fast and extraordinarily versatile file-copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. When copying over ssh, rsync will need to authenticate with the receiving side using either password or key authentication. Since it’s a backup tool, and most of the time will be automated, we want to connect with the receiving side without prompting for password – using key authentication.
Step 1 – Generate RSA keys on the source server
ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is:
Step 2 – Copy the key to the destination server
ssh-copy-id -i root@target-server-domain-or-ip.com root@target-server-domain-or-ip.com's password: Now try logging into the machine, with "ssh 'root@target-server-domain-or-ip.com'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
If you are using an alternate ssh port (not 22), you can try and use this syntax –
ssh-copy-id "-p 1234" user@target-server-domain-or-ip.com
Replace “1234” with your port
Now test ssh connection from the source server to the destination server –
ssh root@target-server-domain-or-ip.com
When doing the first login you will be notified about “RSA key fingerprint” issue, approve it so he will be added “known_hosts” so the alert won’t show up again.
Tags: rsync, ssh
Leave a Reply