How to generate a private key for a certificate(.jks/.crt) file – Unix/Linux



To generate the Private key from the .jks file from linux/unix server.

We can use keytool and openssl utility to generate the private key from a .crt/.jks file.

Command to use:

Go to the location where your certificate file is located.

Using Keytool command generate keystore file

keytool -v -importkeystore -srckeystore keystore.jks -srcalias keyalias -destkeystore keystore.p12 -deststoretype PKCS12

Using Openssl generate the .pem file which contains the  private key

openssl pkcs12 -in keystore.p12 -out keystore.pem

keystore.jks – This file is your certificate file. It will be either in .crt or .jks format.

The keystore.pem contains your private key.

While running the command if it prompts for password you should give it as per the password added while creating a cert file.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s