Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync files from one EC2 instance to another

I was going to do rsync, but rsync over SSH needs to have the private key on the second EC2 instance. I'm concerned about copying my private SSH key to the server. That can't be safe, right?

Is there another possibility, e.g. somehow getting authentication via my computer? If it's only a little auth check at the beginning of each sync, I don't mind that.

Or can I securely sync files between EC2 instances without the private key?

Thanks for your input, MrB

like image 511
MrB Avatar asked Feb 24 '23 08:02

MrB


1 Answers

You needn't use your EC2 keys to setup SSH between the two EC2 instances. Look at this guide - http://ask-leo.com/how_can_i_automate_an_sftp_transfer_between_two_servers.html .

Simple outline of the process is, lets say you want to transfer files from Server1 to Server2. You basically create a new key for your user on Server1 (note this is different from the key you downloaded to access your EC2 instance - Server1 in this case). Then load up the public part in Server2's authorized_keys and you should be able to setup SSH.

If the user that the rsync process is going to run under is not your user, then you will have to setup SSH keys for the user that the process will run under.

HTH

like image 97
arunkumar Avatar answered Mar 04 '23 07:03

arunkumar