Step 1: Generate a key pair by executing below command.
openssl genrsa -des3 -out my_rsa_key_pair 2048
Option -des3 make sure that the pem file generated in the above step will be protected by a passphrase.
$openssl genrsa -des3 -out my_rsa_key_pair 2048
Generating RSA private key, 2048 bit long modulus
..................................+++
..........................+++
e is 65537 (0x10001)
Enter pass phrase for my_rsa_key_pair:
Verifying - Enter pass phrase for my_rsa_key_pair:
$
$ls
my_rsa_key_pair
Step 2: Export public key to publicKey.pem file by executing below command.
openssl rsa -in my_rsa_key_pair -outform PEM -pubout -out publicKey.pem
$openssl rsa -in my_rsa_key_pair -outform PEM -pubout -out publicKey.pem
Enter pass phrase for my_rsa_key_pair:
writing RSA key
$
$ls
my_rsa_key_pair publicKey.pem
$
$cat publicKey.pem
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoIEO7wKib2IWL7+1ehnq
A0tufAXgDREoSlrJRqjfFekdsSzAf3Rcsg7edGARW+4EnJYmUJjYxQ46PxG7WhEx
scU7+fefEzgOFX7qxMB68zG8goU2cACpQSob8slRTdmQEy0dIzIPe4On9T3Q7wmB
SG5NeUTCo0l0hM+8RvCuoSr5HaBapODDkR77wtXuN/PiqsIcEoFQmuQ9BFENB5um
lDo0a1cJ+4rhv6ZLZ3T1jFn6nEvchlCHTpYNhda2UHaK3o9DvTAlbCBDjZxl4Urc
JxiTHIRnK2hbBLEvCUTplXGUFfvHmzzNkfoZiEItcQAMOLLVkOBCZCatm0h6KfXp
BwIDAQAB
-----END PUBLIC KEY-----
No comments:
Post a Comment