How to copy entire folder from Amazon EC2 Linux instance to local Linux machine?
71,401
Solution 1
Call scp
from client machine with recursive option:
scp -r user@remote:src_directory dst_directory
Solution 2
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
Solution 3
scp -i {key path} -r [email protected]:{remote path} {local path}
Solution 4
For EC2 ubuntu
go to your .pem file directory
scp -i "yourkey.pem" -r ec2user@DNS_name:/home/ubuntu/foldername ~/Desktop/localfolder
Solution 5
You could even use rsync.
rsync -aPSHiv remote:directory .
Author by
Mansoor Elahi
Updated on July 09, 2022Comments
-
Mansoor Elahi almost 2 years
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 -
Mansoor Elahi about 12 yearsthis solution helped actually i was trying to copy data without using private key.. scp -i *.pem -r user@remote:src_directory dst_directory
-
Frits over 7 yearsPlease try to avoid just dumping code as an answer and try to explain what it does and why. Your code might not be obvious for people who do not have the relevant coding experience.
-
J. Chomel over 7 yearsyes, While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
-
Silver almost 6 yearsFinally, an answer that includes the -i part. This worked, thanks!
-
Nicolás Rodríguez over 2 yearsI had a error when i tried to do this:
Load key "key.pem": bad permissions
. I've solved by typingchmod 400 key.em
.