Generate Private Key Encrypted with Password Using Openssl

I'm using openssl to sign files, it works but I would like the private key file is encrypted with a password. These are the commands I'm using, I would like to know the equivalent commands using a password:

----- EDITED -----

I put here the updated commands with password:

- Use the following command to generate your private key using the RSA algorithm:

$ openssl genrsa -aes256 -passout pass:foobar -out private.key 2048


- Use the following command to extract your public key:

$ openssl rsa -in private.key -passin pass:foobar -pubout -out public.key


- Use the following command to sign the file:

$ openssl dgst -sha512 -sign private.key -passin pass:foobar -out signature.bin file.txt


- To verify the signature:

$ openssl dgst -sha512 -verify public.key -signature signature.bin file.txt

1 Answer

You can add the "passout" flag, for the "foobar" password it would be: -passout pass:foobar

In your first example it become openssl genrsa -passout pass:foobar -out private.key 2048

You can also use: openssl genrsa -aes256 -out private.key 2048 This will ask you to enter a passphrase.

You can read more here:

5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest