transferring_files_to_ec2_instance
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| transferring_files_to_ec2_instance [2017/07/26 07:11] – walkeradmin | transferring_files_to_ec2_instance [2024/10/02 17:09] (current) – removed walkeradmin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Transferring files to EC2 Instance ====== | ||
| - | <color darkorange> | ||
| - | \\ | ||
| - | \\ | ||
| - | |||
| - | ---- | ||
| - | ===== Introduction ===== | ||
| - | \\ | ||
| - | There are a few ways to transfer files to and from an Amazon EC2 instance. If you are using a desktop environment, | ||
| - | \\ | ||
| - | \\ | ||
| - | 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, | ||
| - | \\ | ||
| - | \\ | ||
| - | Use chmod to change your key.pem file permissions. | ||
| - | \\ | ||
| - | \\ | ||
| - | {{ : | ||
| - | \\ | ||
| - | chmod 0400 keyfile.pem | ||
| - | \\ | ||
| - | The keyfile.pem should now have the following permissions: | ||
| - | \\ | ||
| - | \\ | ||
| - | |||
| - | ---- | ||
| - | ==== File Transfer to EC2 ==== | ||
| - | \\ | ||
| - | 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: | ||
| - | **Public DNS (IPv4): | ||
| - | \\ | ||
| - | \\ | ||
| - | The syntax of SCP is as follows: | ||
| - | \\ | ||
| - | scp -i < | ||
| - | \\ | ||
| - | I am going to transfer a file called TestFile.txt to the home directory on my EC2 Instance, for this I can use the following syntax: | ||
| - | \\ | ||
| - | scp -i keyfile.pem / | ||
| - | \\ | ||
| - | If this is the first time connecting to an instance, you will see the following message: | ||
| - | \\ | ||
| - | \\ | ||
| - | <sxh [text], gutter: false; highlight: 0-0;> | ||
| - | The authenticity of host ' | ||
| - | ECDSA key fingerprint is 02: | ||
| - | Are you sure you want to continue connecting (yes/no)? | ||
| - | </ | ||
| - | \\ | ||
| - | \\ | ||
| - | Type yes and press enter. | ||
| - | \\ | ||
| - | \\ | ||
| - | You should see a transfer confirmation similar to this: | ||
| - | \\ | ||
| - | TestFile.txt | ||
| - | \\ | ||
| - | You can connect to your EC2 Instance via SSH to check the file(s) have copied: | ||
| - | \\ | ||
| - | sudo ssh -i keyfile.pem ec2-user@35.177.4.81 | ||
| - | \\ | ||
| - | <sxh [text], gutter: false; highlight: 0-0;> | ||
| - | Last login: Tue Jul 25 21:16:51 2017 from dsl-217-155-64-20.zen.co.uk | ||
| - | |||
| - | | ||
| - | | ||
| - | ___|\___|___| | ||
| - | |||
| - | https:// | ||
| - | 4 package(s) needed for security, out of 6 available | ||
| - | Run "sudo yum update" | ||
| - | </ | ||
transferring_files_to_ec2_instance.1501053079.txt.gz · Last modified: (external edit)
