Encrypt a file using ssh public keys.

Create ssh public key in PEM format:

 ssh-keygen -f id_rsa.pub -e -m PKCS8 > id_rsa.pem.pub

Use openssl to encrypt/decrypt

Encrypt:

openssl rsautl -encrypt -pubin -inkey ~/.ssh/id_rsa.pem.pub -ssl -in test.txt -out test.txt.enc

Decrypt:

openssl rsautl -decrypt -inkey ~/.ssh/id_rsa -in test.txt.enc -out test.txt.enc.txt