Introduction
Amazon EC2 (Elastic Compute Cloud) is a popular service for hosting applications and storing data. One of the first things you'll need to know is how to transfer files or folders from your local computer to an EC2 instance. This article explains the process step-by-step in simple language and includes screenshots to help you.
Connecting to Your EC2 Instance
To transfer files, you first need to connect to your EC2 instance and follow these steps.
Step 1. Open your terminal (Linux/Mac) or PowerShell (Windows).
Step 2. Use the SSH command to connect to your EC2 instance.
ssh -i "C:\Users\GCS\.ssh\dong key.pem" [email protected]
Note. Replace /path/to/key.pem with your .pem file path and <EC2-Public-IP> with your instance's public IP.
Successful Connection, after running the command, you'll be logged into the EC2 instance. If you see an error, double-check the file path, IP address, and security group settings.
Transferring Files/Folders Using SCP
SCP (Secure Copy Protocol) is the easiest way to transfer files.
Firstly, we will create a folder on EC2 in which we want to send the file.
Here is a command for creating a folder.
mkdir Nescaffe
Use this command to copy a file from your local computer to the EC2 instance.
scp -i "C:\Users\GCS\.ssh\dong key.pem" "C:\Users\GCS\Downloads\Teams Admin Center.jpg" [email protected]:/home/ubuntu/Nescaffe
Verify the File Transfer
After transferring the files, log in to the EC2 instance to check if the files are in the correct location.
cd Nescaffe
ls
Conclusion
In this article, transferring files or folders from your local computer to an Amazon EC2 instance is a simple and secure process when using SCP and SSH. By following the steps outlined, you can easily connect to your EC2 instance, create a folder, and transfer files from your local machine to the instance. This method ensures that your data is transferred securely. For tasks that you need to perform regularly, consider automating the process with tools like AWS CLI or scripts, which will save you time and make the transfer process even more efficient.