Skip to content

Instantly share code, notes, and snippets.

@pedrosancao
Created September 10, 2018 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrosancao/2dec96a987327a82b4b511c19e622ea1 to your computer and use it in GitHub Desktop.
Save pedrosancao/2dec96a987327a82b4b511c19e622ea1 to your computer and use it in GitHub Desktop.
openssl encrypt/decrypt script, requires public key in pem format
#!/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