How to copy entire folder from Amazon EC2 Linux instance to local Linux machine?

Mansoor Elahi picture Mansoor Elahi · Feb 17, 2012 · Viewed 58.2k times · Source

I connected to Amazon's linux instance from ssh using private key. I am trying to copy entire folder from that instance to my local linux machine .

Can anyone tell me the correct scp command to do this?

Or do I need something more than scp? Both machines are Ubuntu 10.04 LTS

Answer

Raymond Lui picture Raymond Lui · Nov 11, 2014

another way to do it is

scp -i "insert key file here" -r "insert ec2 instance here" "your local directory"

One mistake I made was scp -ir. The key has to be after the -i, and the -r after that.

so

scp -i amazon.pem -r ec2-user@ec2-##-##-##:/source/dir /destination/dir