Created
September 10, 2018 13:47
-
-
Save pedrosancao/2dec96a987327a82b4b511c19e622ea1 to your computer and use it in GitHub Desktop.
openssl encrypt/decrypt script, requires public key in pem format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $1 == "-d" ]; then | |
if [ ! -r $2 ]; then | |
echo 'supply a valid input file to decrypt' | |
exit 1 | |
fi | |
openssl rsautl -decrypt -inkey $HOME/.ssh/id_rsa -in $2 2> /dev/null | |
exit 0 | |
fi | |
if [ ! -r $1 ]; then | |
echo 'supply a valid input file to encrypt' | |
exit 1 | |
fi | |
openssl rsautl -encrypt -pubin -inkey $HOME/.ssh/id_rsa.pub.pem -in $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment