This is an old revision of the document!
Table of Contents
Transferring files to EC2 Instance
Jun 2017
Introduction
There are a few ways to transfer files to and from an Amazon EC2 instance. If you are using a desktop environment, then you can use programs like Putty, WinSCP or MobaXterm. These graphically driven programs make transferring files very simple.
However, from the command line it can be a little trickier. In this example we will look at transferring files to and from an Amazon EC2 instance from the Linux command line using SCP.
Get your Key File
To be able to connect to your Amazon EC2 instance you will require your EC2 Instance key pair. Copy your key file to a directory on your source Linux server.
Before we can use the key we have to change its permissions, if you don't do this Amazon will reject the key on security grounds.
Use chmod to change your key.pem file permissions.
chmod 0400 keyfile.pem
The keyfile.pem should now have the following permissions: -r——–. 1 root root 1692 Jul 26 07:47 keyfile.pem
File Transfer
We are now ready to transfer files to and from our EC2 Instance. To connect to the EC2 instance you can use either the currently assigned IP Address, your Elastic IP Address if you have one, or the Public DNS (IPv4).
My test AWS EC2 Intance has the following details.
Elastic IP Address: 35.177.4.81
Public DNS (IPv4): ec2-35-177-4-81.eu-west-2.compute.amazonaws.com
