Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload files and folders to AWS EC2 instance?

Tags:

I use SSH to connect to my Ubuntu instance. With SSH I can administer files and folders on the instance, but how do I upload files and folders from my local machine to the instance?

Is it possible to do right from SSH session, without using SFTP clients?

like image 723
NoobDev4iPhone Avatar asked Jun 04 '12 21:06

NoobDev4iPhone


People also ask

How do I transfer files to AWS 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.


2 Answers

You can try kitten utility which is a wrapper around boto3. You can easily upload/download files and run commands on EC2 server or on multiple servers at once for that matter.

kitten put -i ~/.ssh/key.pem cat.jpg /tmp [SERVER NAME][SERVER IP] 

Where server name is e.g ubuntu or ec2-user etc.

This will upload cat.jpg file to /tmp directory of server

like image 63
Jim Avatar answered Oct 31 '22 22:10

Jim


Just to add a bit more detail to the scp command (included in OSx and most linux/unix):

scp -i myssh.pem local_file [email protected]:/home/username 

Obviously - replace the pem file with the one used for ssh access. Obviously replace "username" and "200.200.200.." with valid values for your setup.

like image 22
user2281015 Avatar answered Oct 31 '22 23:10

user2281015