For the general cases, use:
openssl rsa -in key.pem -pubout -out pubkey.pem
And for the SSH connections, use next:
ssh-keygen -y -f key.pem > key.pub
ssh-keygen -y -f ~/.ssh/id_user_rsa > ~/.ssh/id_user_rsa.pub
@source:
https://www.openssl.org/docs/manmaster/man1/rsa.html
https://stackoverflow.com/a/23413167/1565790