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:
ssh-keygen -t rsa
/root/.ssh/id_rsa
or /home/ec2-user/.ssh/id_rsa
/etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
sudo su
because only then it will allow editing of file /etc/ssh/sshd_config
/home/ec2-user/.ssh/authorized_keys
OR /root/.ssh/authorized_keys
/home/ec2-user/.ssh/id_rsa.pub
OR /root/.ssh/id_rsa.pub
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