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:
KeyPairGenerator generator;
generator = KeyPairGenerator.getInstance("RSA");
// or: generator = KeyPairGenerator.getInstance("DSA");
generator.initialize(2048);
keyPair = generator.genKeyPair();
I can't figure out however how to create the String representation of the PrivateKey and PublicKey in the KeyPair.