How to Upload File to AWS EC2 Instance

0
Upload File to AWS EC2 Instance

We can upload files or directories to AWS EC2 using different ways. In this article, I am going to explain step by step how to upload a file to AWS EC2 instance.

Upload Files and Directories to AWS EC2 Instance

Method 1: Files upload using FTP Client

You can upload your files to the EC2 instance using FTP clients, such as FileZilla, WinSCP, etc. Your EC2 instance should have an FTP setup for this method. If you want to set up FTP on your EC2 instance check here.

Method 2: Files upload to EC2 instance from windows.

If you are using windows system, you can just download and install WinSCP to upload or download website files to AWS EC2 instance. To connect using WinSCP, you will need EC2 instance IP, server ssh key, user name.

Methode 3: Files upload using command prompt

If you are using Ubuntu, Mac or any linux based system, upload files using command prompt to AWS.

For Ubuntu and Mac Users:
  • If you are using Ubuntu or Mac system, you can directly upload files from the local machine to the AWS EC2 instance using SCP command from the terminal.
$ scp -i [login key file path] [Source Files] [username]@[Server IP]:[Destination]

Example:

$ scp -i serverlogin.pem file.zip [email protected]:~

SCP: Secure Copy Protocol.
-i: It is use to specify the new SSH Keypair.
:~ ( colon tild): Tild(~) means the home directory in linux.
  • To download the file from the AWS EC2 instance to the local machine, use the following command.
$ scp -i [login key file path] [username]@[Server IP]:/[Source Files Server] [Destination]

$ scp -i serverlogin.pem [email protected]:/home/ubuntu/file.zip .

. (dot): Here "."(dot) means the location from where you are running the command t download the (file.zip)

Conclusion

In this article, you have learned how to upload file to AWS EC2 instance. If you have any doubt, you can comment below. I will try to answer your questions.

LEAVE A REPLY

Please enter your comment!
Please enter your name here