Using scp to copy a file to Amazon EC2 instance?

HoKy22 picture HoKy22 · Jul 9, 2012 · Viewed 298.1k times · Source

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.

Answer

W.P. McNeill picture W.P. McNeill · Dec 18, 2012

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.