SCP file from local machine to AWS EC2 instance

In that example we will scp a file test.csv from testdb2 to testdb1. Testdb1 is the ec2 instance running redhat on aws and testdb2 is local machine running on redhat.

[root@testdb2 scp_to_aws]$ ls -lrt

total 8

-rw-r--r-- 1 root users 1359 Dec 6 10:28 test.csv

-r-------- 1 root users 1692 May 5 16:14 recovery-key.pem

The pem file should have the file permission shown avobe

Get the Public DNS(IPv4) from AWS EC2 instance

[root@testdb2 scp_to_aws]$ scp -i recovery-key.pem test.csv ec2-user@ec2-52-39-150-239.us-west-2.compute.amazonaws.com:/tmp/

test.csv 100% 1359 1.3KB/s 00:00

In the avobe command we have scp the test.csv file using pem file to testdb1 ec2 inscance in /tmp location.

You can check the file test.csv has been transferred to aws instance testdb1

[ec2-user@ip-172-31-26-102 ~]$ ls -lrt /tmp/

total 4

-rw-r--r--. 1 ec2-user ec2-user 1359 May 7 07:02 test.csv