title: how to make amazon EC2 instances authenticate each other automatically?
body: <p>I am using aws java sdk to launch EC2 instances (running Ubuntu 12.04) and run a distributed tool on them, the tool uses <a href="http://www.open-mpi.org/" rel="nofollow">openMPI</a> for message passing between the nodes and openMPI uses SSH to connect nodes with each other. </p>
  
  <p>The problem is that the EC2 instances don't authenticate each other for SSH connections by default, this <a href="http://techtinkering.com/2009/12/02/setting-up-a-beowulf-cluster-using-open-mpi-on-linux/" rel="nofollow">tutorial</a> shows how to set up SSH by generating keys and adding them to nodes, However, when I tried to add the generated key to the slaves using the command</p>
  
  <pre><code>$ scp /home/mpiuser/.ssh/id_dsa.pub mpiuser@slave1:.ssh/authorized_keys
  </code></pre>
  
  <p>I still got permission denied. Also, after generating new keys, I was not able to log in using the ".pem" key that I got from amazon.</p>
  
  <p>I am not experienced with SSH keys, but I would like to have some way of configuring each EC2 instance (when its firstly created) to authenticate the others, for example by coping a key into each of them. Is this possible and how It could be done?</p>
  
  <p>P.S.: I can connect to each instance once it is launched and can execute any commands on them over SSH. </p>