Skip to content

Instantly share code, notes, and snippets.

@oli-logicnow
Created June 10, 2016 10:04
Show Gist options
  • Save oli-logicnow/61dca21c01c873ae9fc49987ad705b3d to your computer and use it in GitHub Desktop.
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
#!/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