I am not able to scp from one EC2 instance to another EC2 instance. From my laptop I am able to ssh into each instance without issues.
I have two instances.
#worker1
ec2-107-20-7-57.compute-1.amazonaws.com
#master
ec2-50-19-8-109.compute-1.amazonaws.com
Here is what I have done so far.
I made a new key pair on the master node
ssh-keygen -t dsa
I copy-and-pasted the id_dsa.pub from the master node to my laptop
scp -i ec2key.pem ubuntu@ec2-50-19-8-109.compute-1.amazonaws.com:/home/ubuntu/.ssh/id_dsa.pub /Users/me/somefolder
I copy-and-pasted the id_dsa.pub file from my laptop to the worker node
scp -i ec2key.pem /Users/me/somefolder/id_dsa.pub ubuntu@ec2-107-20-7-57.compute-1.amazonaws.com:/home/ubuntu/.ssh
On the worker node I appended the id_dsa.pub file to my authorized_keys file
cat id_dsa.pub >> authorized_keys
I created a file on the master node: /home/ubuntu/test.txt and then tried to scp this file from the master node to the worker node
scp -v -i ubuntu@ec2-50-19-8-109.compute-1.amazonaws.com:/home/ubuntu/.ssh/id_dsa ubuntu@ec2-50-19-8-109.compute-1.amazonaws.com:/home/ubuntu/test.txt ubuntu@ec2-107-20-7-57.compute-1.amazonaws.com:
I got the following result
Permission denied (publickey).
Any ideas?
Additional details:
- I'm using a Mac.
- The end goal is to set up a Beowulf cluster similar to what is mentioned here: http://techtinkering.com/2009/12/02/setting-up-a-beowulf-cluster-using-open-mpi-on-linux/
Best Answer
scp can't take a key from another server, even if that other server is the one you are on. Use a file system path to the identity file you want to use, if scp won't pick it up automatically.
scp -v -i /home/ubuntu/.ssh/id_dsa /home/ubuntu/test.txt ubuntu@ec2-107-20-7-57.compute-1.amazonaws.com:
or scp -v -i /home/ubuntu/test.txt ubuntu@ec2-107-20-7-57.compute-1.amazonaws.com: