Using SSH keys for message encryption ------------------------------------- First convert the ssh public key to PEM format (so 'openssl rsautl' can read it):: ssh-keygen -f ~/.ssh/id_rsa.pub -e -m PKCS8 > id_rsa.pem.pub Then just encrypt the message with openssl rsautl and the converted PEM public-key:: openssl rsautl -encrypt -pubin -inkey id_rsa.pem.pub -ssl -in myMessage.txt -out myEncryptedMessage.rsa The result is the encrypted message in 'myEncryptedMessage.rsa' To decrypt it with the Alice private key:: openssl rsautl -decrypt -inkey ~/.ssh/id_rsa -in myEncryptedMessage.rsa -out myDecryptedMessage.txt Credits: https://superuser.com/questions/576506/how-to-use-ssh-rsa-public-key-to-encrypt-a-text