Skip to content

Instantly share code, notes, and snippets.

@steinfletcher
Created August 20, 2016 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinfletcher/fdd88551f2cc7a0f78c6bcd2d3d2af95 to your computer and use it in GitHub Desktop.
Save steinfletcher/fdd88551f2cc7a0f78c6bcd2d3d2af95 to your computer and use it in GitHub Desktop.
Generate public and private key pair
#!/usr/bin/env bash
# generate a 2048-bit RSA private key
openssl genrsa -out private_tmp_key.pem 2048
# convert private Key to PKCS#8 format (so Java can read it)
openssl pkcs8 -topk8 -inform PEM -in private_tmp_key.pem -out private_key.pem -nocrypt
# generate a public key from the private one
openssl rsa -pubout -in private_tmp_key.pem -out public_key.pem
# cleanup
rm private_tmp_key.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment