Created
June 10, 2016 10:04
-
-
Save oli-logicnow/61dca21c01c873ae9fc49987ad705b3d to your computer and use it in GitHub Desktop.
A script to make encrypting something using somebodies public github key easier
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 -eux | |
# githubencryption.sh github_username file_to_encrypt | |
# NOTE: only works if you've one key in github | |
export tmpfile=$(mktemp /tmp/key.XXXXXX) | |
export tmppem=$(mktemp /tmp/pem.XXXXXX) | |
curl -s -o $tmpfile https://github.com/$1.keys | |
chmod 600 $tmpfile | |
ssh-keygen -f $tmpfile -e -m PKCS8 > $tmppem | |
openssl rsautl -encrypt -pubin -inkey $tmppem -ssl -in $2 -out $2.encrypted | |
echo "To decrypt: openssl rsautl -decrypt -inkey YOUR_PRIVATE_KEY -in $2.encrypted -out $2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment