title: SSH from AWS BeanStalk
body: <p>I have an application that runs on AWS BeanStalk and one requirement is to connect to another server using ssh. I could log as root into the server and generate a key pair that i can use but this would not scale. (we have auto-scaling enabled)</p>
  
  <p>Is there a way to generate and replicate a key pair across the instances that are running?</p>
  
  <p><strong>Edit</strong> - I feel the need to provide a better description to my problem.</p>
  
  <p>When I lunch the BeanStalk instance i selected the previously created keypair but looking at the EC2 documentation <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html" rel="nofollow">here</a> it states the following:</p>
  
  <blockquote>
    <p>Amazon EC2 stores the public key only, and you store the private key.</p>
  </blockquote>
  
  <p>This seems to work ok as I am able to ssh <strong>into</strong> the ec2 instance. We have another service that is running on a <a href="https://www.digitalocean.com/" rel="nofollow">DigitalOcean</a> hosted machine, and we need to ssh <strong>from</strong> the ec2 instance to the digitalocean instance.<br/>
  <strong>Important</strong> The DigitalOcean instance can only allow key based authentication (user/password authentication is not allowed)<br/>
  When i log into the ec2 machine i can see that in the <code>.ssh</code>folder i only have the <code>authorized_keys</code> file and that would make sense taking into consideration the documentation paragraph. 
  Is there a way to get a public key that i could use to log into the digitalocean instance from the ec2 instance?</p>