CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > How to > How to Upload File to AWS EC2 Instance From Local Machine?

How to Upload File to AWS EC2 Instance From Local Machine?

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 ยท 3 min read ยท 0 Comments
Share: in X
FileZilla AWS EC2 2

Amazon Web Services (AWS) Elastic Compute Cloud (EC2) provides a scalable and flexible cloud computing infrastructure for various applications. If you’re working with an AWS EC2 instance and need to transfer files from your local machine, you’ve come to the right place. This step-by-step guide will walk you through the process of uploading files to your AWS EC2 instance easily and securely.

Table of Contents

  • Objective
  • Prerequisite
  • Solution
  • Upload using FileZilla
  • Uploading using the SCP command
    • Step 1: Open a Terminal or Command Prompt
    • Step 2: Set Permissions for the SSH Key Pair
    • Step 3: Transfer Files to EC2 Instance
  • Conclusion

Objective

  • To upload a file into EC2 instance.

Prerequisite

  • EC2 instance is running.
  • You already have a private key file.
  • The port 22 is open

Solution

  • Upload using FileZilla
  • Uploading using the SCP command

Upload using FileZilla

To upload a file using FileZilla we need to have it already installed on our computer. If you don’t have already installed on your computer then you can download it from https://filezilla-project.org/download.php and install.

I am assuming that the FileZilla is installed on your computer.

Steps:

  1. Open the FileZilla
  2. Go to File menu and click Site Manager
  3. Click on New site button (Most probably you can find it in left side)
  4. On the right select General tab.
  5. Choose the Protocol as SFTP (SSH File Transfer Protocol)
  6. Enter the value host name or the public IP address of the EC2 instance for Host and you can leave the port value blank.
  7. Logon Type choose Key file
  8. User ubuntu or ec2-user it depends on the AMI you have configured. Basically, if your ec2 instance is Ubuntu then the user would be ubuntu, ec2-user if it is Amazon Linux Ami and so on.
  9. On the Key file, click on Browse… button and select the PEM file you have saved for the EC2 instance.
  10. Now, click on Connect button. You should be able to connect to your EC2 instance with the FileZilla.
  11. When the connection is successful, you can see the FileZilla something like this image.
  12. You can upload the file from your local site to remote site. Let’s say, you want to upload a file in /home/ubuntu directory of your remote site then you can type /ubuntu/home in the remote site and hit enter.
  13. From the left side, you can choose your file and right click on it then click Upload. You should be able to see the status of the file upload in the bottom of the FileZilla.

Uploading using the SCP command

Step 1: Open a Terminal or Command Prompt

On your local machine, open a terminal (Linux/Mac) or a command prompt (Windows). This is where you will execute the necessary commands to transfer files to your EC2 instance.

Step 2: Set Permissions for the SSH Key Pair

For security reasons, you need to restrict access to your private key file (.pem). On your terminal or command prompt, navigate to the directory containing the .pem file and use the following command:

chmod 400 your-key-pair.pem

Replace “your-key-pair.pem” with the actual filename of your SSH key pair.

Step 3: Transfer Files to EC2 Instance

To transfer files from your local machine to the instance, you can use the secure copy (SCP) command. The basic syntax is as follows:

scp -i your-key-pair.pem /path/to/local/file ec2-user@your-ec2-public-ip:/path/on/ec2/instance

Let’s say, you want to copy your files in the home directory of your EC2 instance where the Ubuntu server is installed. For this you need to use the following command:

scp -i your-key-pair.pem C:\workspace\myfile\myfile.jar [email protected]:/home/ubuntu

The above command should copy the file myfile.jar from your location C:\workspace\myfile to your EC2 instance’s home directory using SCP.

Conclusion

Congratulations! You have successfully learned how to upload files to your AWS EC2 instance from your local machine using a FTP client like FileZilla and SCP.

Related Posts:

  • How to Connect Java Application to a Remote Database…
  • How to Fix SSH Agent Forwarding on macOS: The…
  • Setting Up an EC2 Instance with Amazon CloudFront…
  • How to Login/SSH to AWS EC2 linux instance?
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • Understanding AWS EC2 Instances: A Comprehensive Guide
Tags:devopsec2linuxubuntu
Was this article helpful?
โ† Previous ArticleDelete all directories and keep files in Linux
Next Article โ†’How to fix, “Installation failed: Could not create directory” issue in WordPress?

Leave a Comment Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
ยฉ 2026 CoderSathi. All rights reserved. Privacy Policy ยท Sitemap