# Generate keypair with password via stdin openssl genrsa -aes128 -passout stdin > private.key # Extract public key openssl rsa -in private.key -pubout -out publickey.crt # Encrypt a file using public key openssl rsautl -encrypt -pubin -inkey publickey.crt -in data.txt | base64 > encrypted.txt # Decrypt with password protected private key cat encrypted.txt | base64 -d | openssl rsautl -decrypt -inkey private.key