title: Run ssh-keygen in Ruby to generate VCS deploy keys?
body: <p>I run this command to generate valid deploy keys for my private repos:</p>
  <pre><code>ssh-keygen -b 2048 -t rsa -C &quot;mystring&quot;
  </code></pre>
  <p>The command prompts me for a path and a password (which I leave empty), and generates to files.</p>
  <p>A <code>mykey</code>:</p>
  <pre><code>-----BEGIN OPENSSH PRIVATE KEY-----
  b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
  ...
  -----END OPENSSH PRIVATE KEY-----
  </code></pre>
  <p>And a <code>mykey.pub</code>:</p>
  <pre><code>ssh-rsa AAAAB3NzaC1yc...QDBQl mystring
  
  </code></pre>
  <p>But how can I run this command in pure Ruby and get the results as strings?</p>
  <p>I have tried:</p>
  <pre class="lang-rb prettyprint-override"><code>keypair = OpenSSL::PKey::RSA.new 2048
  keypair.to_pem
  keypair.public_key.to_s
  </code></pre>
  <p>But the files generated do not resemble the one I get with <code>ssh-keygen</code>.</p>
  <p>Anyone who knows how to do this?</p>
  <p>P.s. I have found the <a href="https://github.com/bensie/sshkey" rel="nofollow noreferrer">sshkey</a> gem, but not yet tried it, because I would prefer to avoid using gems for this.</p>