How to generate RSA Keypair

Creating an RSA keypair for JWT(RS256) or other purposes.

$ openssl genrsa -out key.pem 2048
Generating RSA private key, 2048 bit long modulus
.......................................................................+++
..............................................+++
e is 65537 (0x10001)

Extract public key from the key pair.

$ openssl rsa -in key.pem -outform PEM -pubout -out public.pem
writing RSA key