Skip to content

Instantly share code, notes, and snippets.

@davidszotten
Created June 25, 2015 16:14
Show Gist options
  • Select an option

  • Save davidszotten/3fdc144b6b535b9954e6 to your computer and use it in GitHub Desktop.

Select an option

Save davidszotten/3fdc144b6b535b9954e6 to your computer and use it in GitHub Desktop.
Encrypt with github public keys
#! /usr/bin/env bash
set -o nounset
set -o errexit
USER="$1"
INPUT_FILE="$2"
curl -s "https://github.com/$USER.keys" | tail -n 1 > "$USER.pub"
ssh-keygen -f "$USER.pub" -e -m PKCS8 > "$USER.pub.pem"
openssl rsautl -encrypt -pubin -inkey "$USER.pub.pem" < "$INPUT_FILE"
# to decrypt:
# cat $OUTPUT | openssl rsautl -decrypt -inkey ~/.ssh/id_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment