Skip to content

Instantly share code, notes, and snippets.

@bcfurtado
Last active January 19, 2017 17:49
Show Gist options
  • Save bcfurtado/328d570804de56e962384ae3445ea947 to your computer and use it in GitHub Desktop.
Save bcfurtado/328d570804de56e962384ae3445ea947 to your computer and use it in GitHub Desktop.
Creating SSH Keys with Java and Jsch v0.1.54
package com.bcfurtado;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.KeyPair;
import java.io.IOException;
public class App {
public static void main( String[] args ) throws JSchException, IOException {
System.out.println( "Hello World!" );
int type = KeyPair.RSA;
JSch jsch = new JSch();
KeyPair kpair = KeyPair.genKeyPair(jsch, type);
kpair.setPassphrase("");
String filename = "passpie_id_rsa";
kpair.writePrivateKey(filename);
kpair.writePublicKey(filename + ".pub", "");
System.out.println("Finger print: " + kpair.getFingerPrint());
kpair.dispose();
}
}
@bcfurtado
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment