rsync via gateway ssh while defining .pem key

2

1

I need to sync my local files through a gateway to an Amazon EC2 instance that requires specifying my .pem key. I can do this as a three step like so (assuming no typos):

  • rsync -avzh -e ssh /my_site/ user@XX.XX.XX.XX:/temp_destination/
  • ssh to the gateway
  • rsync -avzh -e "ssh - My_Key.pem" temp_destination/ user@XX.XX.XX.XXX:/var/www

I'd like to get this into one single command, but I'm wrestling through the flags and options and can't seem to get anything to work that lets me specify my .pem key.

Thoughts?

Jack McDade

Posted 2013-09-13T18:31:04.700

Reputation: 131

Can't answer my own question for another 7 hours, so in case I forget, I found the answer:

rsync -avzh --stats --progress -e "ssh user@gatway.host ssh -i MY_KEY.pem" ~/Sites/my_site/ user@remote.server:/var/www/ – Jack McDade – 2013-09-13T19:53:35.357

Answers

1

Figured it out, posting the answer for future devs.

rsync -avzh --stats --progress \
  -e "ssh user@gateway.host ssh -i My_Key.pem" \
   ~/Sites/my_site/ \ 
   user@ec2.host:/var/www/

Jack McDade

Posted 2013-09-13T18:31:04.700

Reputation: 131