I\'m looking for a way to programmatically create ssh compatible id_rsa and id_rsa.pub files in Java.
I got as far as creating the KeyPair:
KeyPairG
The generic solution for any PublicKey type (RSA, DSA, etc.) is a one-liner using SSHJ:
PublicKey
byte[] b = new Buffer.PlainBuffer().putPublicKey(key).getCompactData()
and then encode using Base64.getEncoder().encodeToString(b).
Base64.getEncoder().encodeToString(b)