Using scp to copy a file to Amazon EC2 instance?
I am trying to use my Mac Terminal to scp a file from Downloads (phpMyAdmin I downloaded online) to my Amazon EC2 instance.
The command I used was:
scp -i myAmazonKey.pem phpMyAdmin-3.4.5-all-languages.tar.gz [email protected]:~/.
The error I got: Warning: Identity file myAmazonKey.pem not accessible: No such file or directory. Permission denied (publickey). lost connection
Both my myAmazonkey.pem and phpMyAdmin-3.4.5-all-languages.tar.gz are in Downloads, so then I tried
scp -i /Users/Hello_Kitty22/Downloads/myAmazonKey.pem /Users/Hello_Kitty22/Downloads/phpMyAdmin-3.4.5-all-languages.tar.gz [email protected]:~/.
and the error I got: Warning: Identity file /User/Hello_Kitty22/Downloads/myAmazonkey.pem not accessible: No such file or directory. Permission denied (publickey). lost connection
Can anyone please tell me how to fix my problem?
p.s. there is a similar post: scp (secure copy) to ec2 instance without password but it doesn't answer my question.
Solution 1:
Try specifying the user to be ec2-user
, e.g.
scp -i myAmazonKey.pem phpMyAdmin-3.4.5-all-languages.tar.gz [email protected]:~/.
See Connecting to Linux/UNIX Instances Using SSH.
Solution 2:
second directory is your target destination, don't use server name there. In other words, you don't need to mention machine name for the machine you're currently in.
scp -i /path/to/your/.pemkey -r /copy/from/path user@server:/copy/to/path
-r if it's a directory.