Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using scp to copy a file to Amazon EC2 instance?

People also ask

How do I scp to EC2 instance?

Open a new command prompt and run the following command replacing the fields as needed: scp -P 2222 Source-File-Path user-fqdn @localhost: To copy the entire directory instead of a file, use scp -r before the path. This recursively copies all of the directory's contents to the destination EC2 instance.

How do I copy a folder from local to EC2 instance?

To copy the directory from local machine to EC2 instance:scp -i identity_file. pem -r source_dir username@public_ipv4_dns:/remote_dir_path.


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.


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.


Your key must not be publicly viewable for SSH to work. Use this command if needed:

chmod 400 yourPublicKeyFile.pem

You should be on you local machine to try the above scp command.

On your local machine try:

scp -i ~/Downloads/myAmazonKey.pem ~/Downloads/phpMyAdmin-3.4.5-all-languages.tar.gz  [email protected]:~/.

Here are the details of what works for an EC2 instance:

scp -i /path/to/whatever.pem /users/me/path-to-file [email protected]:~

Few notes for beginning:

  1. Note the spaces between the three parameters given after the -i
  2. scp stands for secure copy protocol. Knowing the words makes it easier to remember the command.
  3. -i dictates that you need to give the .pem file as the next param. If there is no -i, than you do not need a .pem.
  4. Note the :~ at the end of the destination for the EC2 instance.

I had exactly same problem, my solution was to

scp -i /path/pem -r /path/file/ ec2-user@public aws dns name: (leave it blank here)

once you done this part, get into ssh server and mv file to desired location