---
title: How to do SCP from one EC2 Instance to another EC2 Instance
description: How to do SCP from one EC2 Instance to another EC2 Instance
---

[![e-Zest logo\_An accion lab company\_Colour](https://blog.e-zest.com/hubfs/images/Logos%20with%20Tagline/Corporate/SVG/e-Zest%20logo_An%20accion%20lab%20company_Colour.svg "e-Zest logo_An accion lab company_Colour")](https://www.e-zest.com/)

- [WORK](https://www.e-zest.com/our-work)
- [SERVICES](https://www.e-zest.com/our-services) 
    - [Product Engineering](https://www.e-zest.com/digital-product-engineering-services)
    - [Enterprise Data Services](https://www.e-zest.com/enterprise-data-services)
    - [Digital Commerce](https://www.e-zest.com/digital-commerce-services)
    - [Digital Operations](https://www.e-zest.com/digital-operations)
    - [Digital Consulting](https://www.e-zest.com/digital-transformation-consulting-services)
    - [Digital Experience Design](https://www.e-zest.com/digital-experience-design)
- [INSIGHTS](https://blog.e-zest.com/)
- [CAREERS](https://www.e-zest.com/careers)
- [ENTERPRISE DATA SERVICES](https://www.e-zest.com/enterprise-data-services)
- [GENERATIVE AI](https://www.e-zest.com/generative-ai)
- [Healthcare](https://healthcare.e-zest.com)
- [Contact Us](https://www.e-zest.com/contact-us)

- ![Elevating Product Engineering with AI and ML](https://blog.e-zest.com/hubfs/Elevating%20Product%20Engineering%20with%20AI%20and%20ML.jpg)

  [BLOGS](https://blog.e-zest.com)
  
  #### Elevating Product Engineering with AI and ML

  As technology evolves and customer choices broaden, there is an increasing ...

  [Read more](https://blog.e-zest.com/elevating-product-engineering-with-ai-and-ml)
- ![e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024](https://blog.e-zest.com/hubfs/e-Zest%20%E2%80%93%20An%20Accion%20Labs%20Company%20-%20Gets%20Recognition%20as%20a%20Contender%20in%20the%20ISG%20Provider%20LensTM%20Study%20on%20Digital%20Engineering%20Services%202024.jpg)

  [NEWS](https://blog.e-zest.com/news)
  
  #### e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024

  We are delighted to announce that e-Zest – An Accion Labs Company has been ...

  [Read more](https://blog.e-zest.com/news/e-zest-an-accion-labs-company-gets-recognition-as-a-contender-in-the-isg-provider-lens-study-on-digital-engineering-services-2024)
- ![e-Zest Solutions supports Digital Pune Mission](https://blog.e-zest.com/hubfs/blog-files/Digital%20Literacy%20Bus%20e-Zest.png)

  [CSR](https://blog.e-zest.com/csr)
  
  #### e-Zest Solutions supports Digital Pune Mission

  **Pune, India:** e-Zest Solutions, a leading digital technology innovation ...

  [Read more](https://blog.e-zest.com/csr/e-zest-solutions-supports-digital-pune-mission)

- [Work](https://www.e-zest.com/our-work)
- [Services](https://www.e-zest.com/our-services)
- [Insights](https://blog.e-zest.com)
- [Careers](https://www.e-zest.com/careers)
- [Enterprise Data](https://www.e-zest.com/enterprise-data-services)
- [Generative AI](https://www.e-zest.com/generative-ai)
- [Innovations](https://www.e-zest.com/innovations)
- [Healthcare](https://healthcare.e-zest.com)
- [About](https://www.e-zest.com/about-us)
- [Contact](https://www.e-zest.com/contact-us)

- [Blog](https://blog.e-zest.com/)
- [News](https://blog.e-zest.com/news)
- [CSR](https://blog.e-zest.com/csr)

- [![Linkedin Icon](https://blog.e-zest.com/hubfs/icons/linkedin_icon_white.svg)](https://www.linkedin.com/company/e-zest-solutions/)
- [![Twitter Icon](https://blog.e-zest.com/hubfs/twitter-logo-silhouette%20(5).svg)](https://twitter.com/ezest)
- [![Facebook Icon](https://blog.e-zest.com/hubfs/facebook-app-logo%20(4).svg)](https://www.facebook.com/61259256638)
- [![Instagram Icon](https://blog.e-zest.com/hubfs/instagram-logo%20(4).svg)](https://www.instagram.com/ezestsolutions/)
- [![Youtube Icon](https://blog.e-zest.com/hubfs/icons/youtube_icon_white.svg)](https://www.youtube.com/user/ezestcorporate)

[![Go to top icon](https://blog.e-zest.com/hubfs/AA%20Assets/top%20button.svg)](https://blog.e-zest.com/how-to-do-scp-from-one-ec2-instance-to-another-ec2-instance/#top)

Hit enter to search or ESC to close

Insights

e-Zest members share technology ideas to foster digital transformation.

- [Blog](https://blog.e-zest.com)
- [News](https://blog.e-zest.com/news)
- [Podcasts](https://www.e-zest.com/podcasts)
- [Healthcare](https://blog.e-zest.com/healthcare)
- [CSR](https://blog.e-zest.com/csr)
- [Whitepaper](https://blog.e-zest.com/whitepaper)
- [Playbook](https://blog.e-zest.com/playbook)
- [Media Kit](https://www.e-zest.com/media-kit)

# How to do SCP from one EC2 Instance to another EC2 Instance

[Vivek Danej](https://blog.e-zest.com/author/vivek-danej)  Oct 10, 2012

[sftp](https://blog.e-zest.com/topic/sftp) [AWS](https://blog.e-zest.com/topic/aws) [ssh](https://blog.e-zest.com/topic/ssh) [Linux](https://blog.e-zest.com/topic/linux) [SCP Command](https://blog.e-zest.com/topic/scp-command) [scp rsync](https://blog.e-zest.com/topic/scp-rsync) [EC2](https://blog.e-zest.com/topic/ec2) [cloud computing](https://blog.e-zest.com/topic/cloud-computing-2) [Technology](https://blog.e-zest.com/topic/technology)

- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/how-to-do-scp-from-one-ec2-instance-to-another-ec2-instance/&title=&summary=&source=>
- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/how-to-do-scp-from-one-ec2-instance-to-another-ec2-instance/&text=How%20to%20do%20SCP%20from%20one%20EC2%20Instance%20to%20another%20EC2%20Instance>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/how-to-do-scp-from-one-ec2-instance-to-another-ec2-instance/>
- <https://www.instagram.com/ezestsolutions/?u=https://blog.e-zest.com/how-to-do-scp-from-one-ec2-instance-to-another-ec2-instance/>

Nowadays, many websites are being hosted on cloud (Amazon Web Services) instead of traditional dedicated/shared Linux servers. Programmers who are using "scp" command to copy data from one Linux server to other Linux server are now facing issues to use same "scp" command for two ec2 instances/servers of AWS. The main reason behind this is, while using "scp" command, it asks for password of the server where the data is being copied and with ec2 instances of AWS, we normally have .ppk files and not a password.

Here is a solution for all the guys facing similar issue. If you implement this solution you can use scp command on ec2 instances without a password.

**Steps to be followed:**

1. Steps to perform on first EC2 Instance (call server 1) 
     1. Generate the keypair on server 1 on which you plan to run scp, ssh, sftp or rsync
     2. Login to server through shell and run the following command from anywhere  
        `ssh-keygen -t rsa`
     3. It usually shows location where files will be generated  
        `/root/.ssh/id_rsa` or `/home/ec2-user/.ssh/id_rsa`
     4. Do not enter any passphrase
2. Steps to perform on second EC2 Instance (call server 2) 
     1. Check the "sshd\_config" on that server
     2. Typically it’s present in `/etc/ssh/sshd_config`
     3. Please uncomment following two lines in sshd\_config  
        `RSAAuthentication yes`  
        `PubkeyAuthentication yes`  
         Note =\> If you are logged in as EC2 User. Please do `sudo su` because only then it will allow editing of file `/etc/ssh/sshd_config`
     4. Now find authorized\_keys file of server2
     5. Location of authorized\_keys file of server 2 as  
        `/home/ec2-user/.ssh/authorized_keys` OR `/root/.ssh/authorized_keys`
     6. Next step is to append contents of **id\_rsa.pub file of server 1** to **authorized\_keys file of server 2**
     7. Location of id\_rsa.pub file of server 1 as  
        `/home/ec2-user/.ssh/id_rsa.pub` OR `/root/.ssh/id_rsa.pub`
     8. Once you copy the contents of id\_rsa.pub file of server1 to authorized\_keys file of server2, YOU ARE DONE !

You will have to follow same steps if you want to run ssh, rsync or sftp commands.

**Example:**

Now command to fire on server 1  
`scp test1.txt ec2-user@ip-10-252-1-56.us-west-2.compute.internal:/home/ec2-user/`  
 where `ec2-user@ip-10-252-1-56.us-west-2.compute.internal` is Private DNS of server 2  
 You will get Private DNS of ec2 instance at AWS console

 

**Reference Link:**

[http://askleo.com/how\_can\_i\_automate\_an\_sftp\_transfer\_between\_two\_servers.html](http://ask-leo.com/how_can_i_automate_an_sftp_transfer_between_two_servers.htmlhttp://)

- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/how-to-do-scp-from-one-ec2-instance-to-another-ec2-instance/&text=How%20to%20do%20SCP%20from%20one%20EC2%20Instance%20to%20another%20EC2%20Instance>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/how-to-do-scp-from-one-ec2-instance-to-another-ec2-instance/>
- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/how-to-do-scp-from-one-ec2-instance-to-another-ec2-instance/&title=&summary=&source=>

### Similar Blog

[Setting up SFTP Server on Amazon EC2 SFTP also known as SSH File Transfer Protocol, enables a secured data transfer between SFTP server and client machine. SFTP ... By Amit Tidke Apr 05, 2017](https://blog.e-zest.com/setting-up-sftp-server-on-amazon-ec2)

[![Simple steps to change size of EBS volume in EC2 of AWS using AWS console](https://blog.e-zest.com/hs-fs/file-3443237167-png/blog-files/step1-create-snapshot-existing-volume.png)](https://blog.e-zest.com/simple-steps-to-change-size-of-ebs-volume-in-ec2-of-aws-using-aws-console/)

[Simple steps to change size of EBS volume in EC2 of AWS using AWS console](https://blog.e-zest.com/simple-steps-to-change-size-of-ebs-volume-in-ec2-of-aws-using-aws-console/)

[I found many of us who use EC2 (Amazon Elastic Compute Cloud) instances of](https://blog.e-zest.com/simple-steps-to-change-size-of-ebs-volume-in-ec2-of-aws-using-aws-console/)[AWS (Amazon Web Services)](https://blog.e-zest.com/cloud-computing-services/amazon-web-services/) face issue of increasing ...

By Vivek Danej May 31, 2012

## Helping Organizations Thrive in the Digital Age

[Contact Us](https://www.e-zest.com/contact-us)

- [About](https://www.e-zest.com/about-us)
- [Services](https://www.e-zest.com/our-services)
- [Work](https://www.e-zest.com/our-work)
- [Insights](https://blog.e-zest.com/)
- [Healthcare](https://healthcare.e-zest.com/)
- [Accion Labs](https://www.accionlabs.com/)

- <https://www.linkedin.com/company/e-zest-solutions/>
- <https://twitter.com/ezest>
- <https://www.facebook.com/eZest/>
- <https://www.instagram.com/ezestsolutions/>
- <https://www.youtube.com/user/ezestcorporate>

- Dallas
- Detroit
- Hannover
- Vienna
- London
- Pune

 © 2025 e-Zest Solutions

- [Privacy Policy](https://www.e-zest.com/privacypolicy)
- [Cookie Policy](https://www.e-zest.com/cookie-policy)

 Contact us

 Contact us

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.