Upload a file to AWS from the local machine

How to use scp command to upload a file to aws server

  • I have a .pem file in /Downloads on the local computer
  • I am trying to copy a file to the /images folder on an AWS server

    Which command can I use?

Thanks,

+9
amazon-web-services amazon-ec2
source share
5 answers

You can use simple scp :

 scp -i ~/Downloads/file.pem local_image_file user@ec2_elastic_ip:/home/user/images/ 

You need to put Elastic IP in the EC2 instance, open port 22 on your local computer IP address in the security group of the EC2 instance and use the right user (it can be ec2-user, admin or ubuntu (see AMI)).

+25
source share

there are several ways to achieve the desired

+3
source share

Answers Diego. However, if you do not know your elastic IP, you can simply scp use the following command (check the order of the arguments)

scp -i path-to-your-identifier.pem file to copy ubuntu @ public-IP: / required-path

for reference only, here ubuntu is your AWS user, and public-IP somewhat similar to 54.2xx.xxx.xxx, for example. 54.200.100.100 or such (If the order is corrupted: the file name is before the identifier, then you will get a Permission denied (publickey).lost connection )

Also, keep in mind the permissions of the .pem file .. Must be 400 or 600. Not available to everyone. Hope this helps!

+2
source share

Another alternative way to scp is rsync .

Some of the benefits of rsync

rsync cmd

 rsync -ravze "ssh -i /home/your-user/your-key.pem " --exclude '.env' --exclude '.git/' /var/www/your-folder-to-upload/* ubuntu@xx.xxx.xxx.xxx:/var/www/your-remote-folder 

Now, if you find this syntax a bit detailed, you can use aws-upload , which does all of the above, but you just use tabbing,

0
source share

Here are the detailed instructions that the course tutor on the forums in the Udacity Deep Learning nanodegrad referred to: how to upload files to an AWS instance

-one
source share

All Articles