ssh-keygen -f id_rsa.pub -e -m PKCS8 > id_rsa.pkcs8.pubkey
One way to obtain a recipient's public key is from GitHub, by adding .keys
to their profile url, e.g. https://github.com/noamnelke.keys
This pipes a secret string into openssl, encrypts it with the recipient's public key and pipes the result to openssl again to transcode it into base64 (without the last step it would be binary, which is fine for a file, but harder to paste somewhere).