How to Copy Files to an AWS EC2 Instance Using WinSCP and SFTP

This tutorial will show you how you can transfer files from your local machine running Windows to an AWS EC2 or Lightsail instance using SFTP and the WinSCP client.

Prerequisites

  1. You have created the instance using EC2 using the Amazon Linux AMI or AWS Lightsail
  2. You are using a Windows computer
  3. You have a .ppk private key – see How to Create a PPK file from a PEM file – Windows 10
  4. You have downloaded and installed the free WinSCP SFTP, SCP and FTP client for Windows



Transferring files to the EC2 Instance

Step 1 – Open WinSCP

Step 2 –  Click on Session, New Session or press Ctrl+N

How to Copy Files to an AWS EC2 Instance Using SFTP
Use Ctrl+N to connect to a new site

Step 3 – Click on ‘New Site’

Step 4 – Enter the public IP address for your instance in the Host name field

How to Copy Files to an AWS EC2 Instance Using SFTP
Enter the Host Name, User Name, then click on ‘Advanced’

Step 5 – Enter the User name – if connecting to a standard EC2 instance using the Amazon Linux AMI the  user name will be  ec2-user, if it is a Bitnami WordPress instance it will be bitnami

Step 6 – Click on Advanced to add the private key file for authentication

Step 7 – Click on Authentication

How to Copy Files to an AWS EC2 Instance Using SFTP
How to Copy Files to an AWS EC2 Instance Using SFTP

Step 8 – In the Private key file field click to browse for the .ppk private key file for the instance you created from the .pem file provided by AWS and click ‘OK’.

How to Copy Files to an AWS EC2 Instance Using SFTP
How to Copy Files to an AWS EC2 Instance Using SFTP

Step 9 – Save the session by clicking on ‘Save’ under the User Name – at this point you can name the session so you don’t have to upload the key next time you want to connect to the instance.

Step 10 – Click on ‘Login’ on the Login dialog, and the program will connect to the instance. You should see the directory tree.

Troubleshooting

If you have any problems, check:

  • The host name is correct
  • The user is correct
  • The private key file (.ppk) is correct for the instance – check the AWS key pair used