To upload files from your local Windows machine to an Amazon EC2 instance, you can use SSH/SFTP clients like WinSCP or PuTTY’s
pscp, or use the
scp command from Windows Subsystem for Linux.
Let’s go with the WinSCP option since it has a graphical interface and is easy to use.
Here is a step-by-step guide:
Step 1: Install WinSCP
You can download it from its official website. After downloading, follow the steps to install it on your machine.
Step 2: Connect to your EC2 instance
Open WinSCP. In the “Session” screen, fill in the details as follows:
- File protocol: SFTP
- Host name: Your EC2 instance’s Public DNS or IP. You can find this in your AWS EC2 console.
- Port number: 22
- User name: Depending on the AMI you are using, it might be “ec2-user”, “ubuntu”, “root”, etc.
- Password: EC2 instances are usually accessed using key pairs, not passwords. Leave it blank.
In the same “Session” screen, click on “Advanced…” button.
Under “SSH”, select “Authentication”.
Here, you can browse and select your private key file (
.ppk) you got when you created your EC2 instance. If your key is not in the
.ppk format (for example, it’s in
.pem format), you need to convert it using PuTTYgen.
Step 3: Upload files
Once you’re logged in, you can see two panes. The left pane is your local machine, and the right pane is your EC2 instance. You can simply drag and drop files or directories between these two panes to upload/download files.
If you want to use
scp command in Windows Subsystem for Linux (WSL) or PuTTY’s
pscp, the process is slightly different, and you would need to be comfortable with command-line tools. Also, note that you should adjust the permissions of the key file and the uploaded files if necessary, to avoid any permission-related issues.
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.