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.

How to transfer files

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