In this tutorial, I will teach you how to upload files to your EC2 instance using PhpStorm’s inbuilt SFTP client.
- You have installed and opened a copy of the PhpStorm Integrated Development Environment (IDE)
- You have an AWS EC2 instance running and have a public IP address and private key file for the instance – see How to Create a PPK file from a PEM file – Windows 10
Connecting to your EC2 instance using PHPStorm
Step 1 – Go to File >> Settings or press Ctrl+Alt+S
Step 2 – Click on Build, Execution, Deployment
Step 3 – Click on Deployment
Step 4 – Click on the ‘+’ sign (or press the Insert key) to create a new remote connection
Step 5 – Enter the following:
- Type: SFTP
- Port: 22
- SFTP host: the public IP address of your EC2 instance
- User name: the user name usually ec2-user
- Auth type: Key pair (OpenSSH or PuTTY)
- Private key file: click to upload the private .ppk key file for your instance
Step 6 – Click on TEST SFTP CONNECTION button – it should connect
Step 7 – Click OK to save the connection
You should now see ‘Remote Host’ and be able to drag and drop files from your local machine to the EC2 instance.
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.
- You have created the instance using EC2 using the Amazon Linux AMI or AWS Lightsail
- You are using a Windows computer
- You have a .ppk private key – see How to Create a PPK file from a PEM file – Windows 10
- 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
Step 3 – Click on ‘New Site’
Step 4 – Enter the public IP address for your instance in the Host name field
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
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’.
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.
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