OpenSSL private and public keys has many uses. You can find it on HTTPS web server, GPG, OpenSSH, etc. It is asymmetric cryptography where public key can only decrypted by its private key. You can read more here.

So lets get going on how to create our own private and public key.

  1. Create private key
    openssl genrsa -out my_private_key.pem 4096

  2. Create public key
    openssl rsa -in my_private_key.pem -outform PEM -pubout -out my_public_key.pem

That's it. Now you have your own private and public key in your current directory. Remember to keep your private key in safe place.