Generating RSA Keys using OpenSSL command line

Generate 2048 bit private-public key pair

openssl genrsa -des3 -out private.pem 2048

You will be prompted for a passphrase for private key, make sure you remember the passphrase you use.

openssl rsa -in private.pem -outform PEM -pubout -out public.pem

If you want unencrypted private key, you can get it with the following command (optional)

openssl rsa -in private.pem -out private_unencrypted.pem -outform PEM

Official OpenSSL docs reference