Is there any way to create private and public keys with one command? The classic way is two commands
$openssl genrsa -out privkey.pem 2048
and after that
$openssl rsa -in privkey.pem –pubout –out pubkey.pem
I tried with | (pipe) but no.
Information Security Stack Exchange is a question and answer site for information security professionals. It only takes a minute to sign up.
Sign up to join this communityOK, since noone is trying to answer this I have few tips. OpenSSL doesn't seem to know that.
If you need to use pipe with the private key in stdin, you can use following. E.g. to output the pubkey right away (in fact, it is useless since you don't save the privkey):
openssl genrsa 2048 | ....
openssl genrsa 2048 | openssl rsa -pubout
You can use ssh-keygen
for similar thing. The following will print the pub/priv rsa key pair with empty passphrase, but afaik it's in a bit different format than the OpenSSL would give you.
ssh-keygen -t rsa -f file -P ""
And then there is the fact that using &&
or two separate commands should be okay for most situations.
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX
see the accepted answer to this stackoverflow question
openssl genrsa ... | tee private.pem | openssl rsa -pubout >public.pem
. Or in 1.0.0+ you can use genpkey
and pkey
instead, but for RSA there's no benefit.
Jul 5, 2014 at 7:43
&&
?