Search code examples
amazon-web-servicesamazon-ec2scpubuntu-14.04

Transferring Files between two EC2 Instances in the same region


I have 2 EC2 instances running Ubuntu 14.04 and I need to figure out how to transfer files from one to another. I read the FAQs from Amazon and it says that I can do this without incurring any additional costs if I use the private IP but I am not sure how to transfer the files using that.

Right now I use the scp protocol to do this -

scp -i ~/Path-To-Key-File/AAA.gem /path/file  ec2-user@<Elastic IP>:/path/file

I tried replacing the elastic IP with private IP but it doesn't work. Am I doing something wrong here?


Solution

  • Actually, I figured it out ... I just needed to replace the Elastic IP with the private IP and configure the security groups properly to allow instances to communicate!

    Transferring from Machine A to Machine B

    I am running this code on machine A

    scp -i ~/Path-To-Key-File/AAA.pem /path/file  ec2-user@<Private IP of Machine B>:/path/file
    

    For security groups, I had to allow SSH protocol over the private IP (from Machine B)!!