title: How to do I convert the PublicKey to OpenSSH authorized_keys format
body: <p>Here is the code to get the public key. I need to convert the public key to OpenSSH format to add it to the <code>authorized_keys</code> file in Linux. How can I do that?</p>
  
  <pre><code>KeyPairGenerator kpGen = KeyPairGenerator.getInstance("DSA", "BC");
  kpGen.initialize(1024, new SecureRandom());
  KeyPair keypair = kpGen.generateKeyPair();
  </code></pre>
  
  <p>I did use <code>PEMWriter</code>. But it didn't give the output string in proper format.</p>