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.
In this tutorial I will show you how you can copy files from S3 to an Amazon Web Services EC2 instance using the AWS Command Line Interface (CLI).
The basic concept of the AWS CLI S3 commands is that you have two types of path arguments: LocalPath and S3Uri.
The LocalPath is the local file or directory. The S3Uri is the location of a S3 object or bucket written in the form S3://mybucket/myobjectkey.
In each command, one path argument represents the source and the other the destination.
- You have an EC2 instance running and can get access to it using SSH
- You have configured the AWS CLI on your instance using keys with read/write access to S3 – see How to Configure the AWS CLI
- You have a bucket or buckets set up containing some test files or objects
Copying a file to S3
aws s3 cp MyFile.txt s3://my-bucket/path/
Moving all files from S3
aws s3 mv s3://my-bucket/path ./MyDirectory --recursive
Removing a file from S3
aws s3 rm s3://my-bucket/path/MyFile.txt
Syncing current directory with a S3 bucket
aws s3 sync . s3://my-bucket/path
Delete all contents of a bucket
aws s3 rm s3://my-bucket/path --recursive
List all buckets
aws s3 ls
List contents of a bucket
aws s3 ls s3://bucket-name
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