xxxxxxxxxx
openssl rsa -in private.key -pubout > public.key
xxxxxxxxxx
# will extract the public key and print that out
openssl rsa -in mykey.pem -pubout > mykey.pub
# To get a usable public key for SSH purposes
ssh-keygen -y -f key.pem > key.pub
xxxxxxxxxx
chmod 400 ~/.ssh/id_rsa
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub