The following command generates a file which contains both public and private key:
openssl genrsa -des3 -out privkey.pem 2048
With OpenSSL, the private key contains the public key information as well, so a public key doesn't need to be generated separately
How can we extract the public key from the privkey.pem file?
This question is tagged with
~ Asked on 2012-04-22 19:12:57
openssl rsa -in privkey.pem -pubout > key.pub
That writes the public key to
~ Answered on 2012-04-22 19:19:02
Though, the above technique works for the general case, it didn't work on Amazon Web Services (AWS) PEM files.
I did find in the AWS docs the following command works:
edit Thanks @makenova for the complete line:
ssh-keygen -y -f key.pem > key.pub
~ Answered on 2014-05-01 17:36:29