amazon-web-services - with - transfer files to ec2 linux instance




scp(secure copy) to ec2 instance without password (8)

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, when I want to copy a file to the instance using scp I am asked to enter a password:

scp somefile.txt -i mykey.pem [email protected]:/

Password:

Any ideas why this is happening/how it can be prevented?


scp -i /home/barkat/Downloads/LamppServer.pem lampp_x64_12.04.tar.gz

this will be very helpful to all of you guys


I figured it out. I had the arguments in the wrong order. This works:

scp -i mykey.pem somefile.txt [email protected]:/

I've used below command to copy from local linux Centos 7 to AWS EC2.

scp -i user_key.pem file.txt [email protected]:/home/ec2-user

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.


Making siliconerockstar's comment an answer since it worked for me

scp -i kp1.pem ./file.txt [email protected]:/home/ec2-user


My hadoopec2cluster.pem file was the only one in the directory on my local mac, couldn't scp it to aws using scp -i hadoopec2cluster.pem hadoopec2cluster.pem [email protected]:~.

Copied hadoopec2cluster.pem to hadoopec2cluster_2.pem and then scp -i hadoopec2cluster.pem hadoopec2cluster_2.pem [email protected]:~. Voila!


write this code

scp -r -o "ForwardAgent=yes" /Users/pengge/11.vim [email protected]:/root/

If you have a SSH key with access to the destination server and the source server does not, adding -o "ForwardAgent=yes" will allow you to forward your SSH agent to the source server so that it can use your SSH key to connect to the destination server.






pem