I am desperately trying to copy some files from AWS EC2 machine but I am struggling with following.
- I am able to copy only some files from already existing folder (although I want to to copy all the files recursively to my local machine)
scp
andrsync
complains that path doesn't exist when I create completely new file in some location (let's say/home/ec2-user/a.txt
)
The command I am using is
scp -rpi ~/.ssh/my-key.pem ec2-user@52.29.216.47:/home/ec2-user/a.txt
I created the file under ec2-user with touch a.txt
so the permissions should be fine (if that even matters).
Contents of original folder I want to copy is
-rw-r--r-- 1 webapp webapp 90 17. úno 2015 cron.yaml
drw-r--r-- 2 ec2-user ec2-user 4096 1. dub 13.09 db-backup
-rw-r--r-- 1 webapp webapp 2703 17. úno 2015 index.php
-rw-r--r-- 1 webapp webapp 189 17. úno 2015 logo_aws_reduced.gif
drwxrwxrwx 15 ec2-user ec2-user 4096 1. dub 17.35 martintour
drw-r--r-- 14 ec2-user ec2-user 4096 30. bře 20.52 master_martintour
-rw-r--r-- 1 webapp webapp 367 17. úno 2015 scheduled.php
-rw-r--r-- 1 webapp webapp 3490 17. úno 2015 styles.css
However only this part is copied
-rw-r--r-- 1 pmensik pmensik 90 úno 17 2015 cron.yaml
-rw-r--r-- 1 pmensik pmensik 2703 úno 17 2015 index.php
-rw-r--r-- 1 pmensik pmensik 189 úno 17 2015 logo_aws_reduced.gif
-rw-r--r-- 1 pmensik pmensik 367 úno 17 2015 scheduled.php
-rw-r--r-- 1 pmensik pmensik 3490 úno 17 2015 styles.css
So it seems like the -r
option is not working. And also it doesn't explain why I cannot copy newly created files or folders like I mentioned previously.
The command I used for this is
scp -rpi ~/.ssh/my-key.pem ec2-user@52.29.216.47:/var/app/current .
I've already played with changing the permissions but no I am completely lost.
Best Answer
You are missing the destination directory.
Try:
scp -rp -i ~/.ssh/my-key.pem ec2-user@52.29.216.47:/home/ec2-user/a.txt /your/local/dir/