Ubuntu

Rsync: Create SSH-Key for Cron Backups

Reference: http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/

1. Create a Key on the "Origin Server"

# ssh-keygen

root@Asterisk:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

Press enter to create the SSH Key without a password (not sure of the no password implications, in our case our servers are behind a firewall so I'm not worried about security issues)

2. Copy the Key to "Destination" Server

# ssh-copy-id -i ~/.ssh/id_rsa.pub admin@destinationip

root@Asterisk:~# ssh-copy-id -i ~/.ssh/id_rsa.pub admin@192.168.1.232
The authenticity of host '192.168.1.232 (192.168.1.232)' can't be established.
ECDSA key fingerprint is XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
admin@192.168.1.232's password:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'admin@192.168.1.232'"
and check to make sure that only the key(s) you wanted were added.

3. Test if the Key transfer has been succesful

To check this, try to SSH to the other server and if access is granted without requesting password the Key is correctly installed

#ssh user@destinationip

Importante Consideration...

 

4. Try doing some rsync tests.

rsync -az /var/spool/asterisk/monitor/test.wav root@192.168.X.X:/volume1/NetBackup/Servers/MIA/Asterisk

Attachments:

Leave a Reply

Your email address will not be published. Required fields are marked *