Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload local system files to Amazon EC2 using ssh?

Tags:

ssh

amazon-ec2

I have taken a free account of EC2 and setup LAMP on it, since my website was hosted on godaddy and its have a heavy chunk of data. Is there any way that I can transfer my files directly from godaddy or upload code from my local system?

like image 451
shekhardtu Avatar asked Jan 19 '16 06:01

shekhardtu


1 Answers

**Transferring Files between your laptop and Amazon instance ** For linux/Unix/Mac system, we can use a command-line tool “scp” to transfer files between your laptop and Amazon instance. Also we can use a GUI tool “FileZilla” to do the transfer, which is more user-friendly.

Using scp to transfer data “scp” means “secure copy”, which can copy files between computers on a network. You can use this tool in a Terminal on a Unix/Linux/Mac system.

To upload a file from your laptop to Amazon instance:

$scp -i ~/Desktop/amazon.pem ~/Desktop/MS115.fa  [email protected]:~/data/

This command will upload a file - MS115.fa in your ~/Desktop/ folder of your laptop to folder ~/data/ on an Amazon instance. Note you still need to use the private key you used to connect to the Amazon instance with ssh. (In this example, it is the amazon.pem file in ~/Desktop/.

Note: You need to make sure that the user “ubuntu” has the permission to write in the target directory. In this example, if ~/data/ was created by user “ubuntu”, it should be fine.

Similarly, to download a file from Amazon instance to your laptop:

$scp -i ~/Desktop/amazon.pem [email protected]:/data/ecoli_ref-5m-trim.fastq.gz ~/Download/

This command will download a file /data/ecoli_ref-5m-trim.fastq.gz from Amazon instance to your ~/Download folder in your laptop.

Note: You can use asterisk(*) to download multiple files, like *.fasta.gz.

Also you can follow the GUI tool "File Zilla" to perform the same task. To using File Zilla please follow the attached link:

http://angus.readthedocs.org/en/2014/amazon/transfer-files-between-instance.html

like image 70
shekhardtu Avatar answered Nov 15 '22 12:11

shekhardtu