I have an EC2 instance running (FreeBSD 9 AMI ami-8cce3fe5), and I can ssh into it using my amazon-created key file without password prompt, no problem.
However, whe
lets assume that your pem file and somefile.txt you want to send is in Downloads folder
scp -i ~/Downloads/mykey.pem ~/Downloads/somefile.txt root@my.ec2.id.amazonaws.com:~/
let me know if it doesn't work
In your case, the user root
won't have any issues. But in certain cases where you're required to login under SSH as a different user, make sure the directory you're scp
-ing has adequate permissions for the user you're SSH-ing.
scp -i ~/.ssh/key.pem ec2-user@ip:/home/ec2-user/file-to-copy.txt .
The file name shouldnt be between the pem file and the ec2-user string - that doesnt work. This also allows you to reserve the name of the copied file.
Making siliconerockstar's comment an answer since it worked for me
scp -i kp1.pem ./file.txt ec2-user@1.2.3.4:/home/ec2-user
I've used below command to copy from local linux Centos 7 to AWS EC2.
scp -i user_key.pem file.txt ec2-user@my.ec2.id.amazonaws.com:/home/ec2-user
scp -i /home/barkat/Downloads/LamppServer.pem lampp_x64_12.04.tar.gz
this will be very helpful to all of you guys