Skip to content

Instantly share code, notes, and snippets.

@ggrandes
Last active April 25, 2017 14:47
Show Gist options
  • Select an option

  • Save ggrandes/09bc477ac20b8fcb0565d68b8aebe40e to your computer and use it in GitHub Desktop.

Select an option

Save ggrandes/09bc477ac20b8fcb0565d68b8aebe40e to your computer and use it in GitHub Desktop.
GnuPG Examples
#!/bin/bash
# Original Source:
# https://gist.github.com/ggrandes/09bc477ac20b8fcb0565d68b8aebe40e
#
date_log () {
printf '%(%Y-%m-%dT%H:%M:%S%z)T %s\n' -1 "$*"
}
recipients=(--trust-model always)
recipients+=(--keyring "./user.pub" --secret-keyring "./user.sec")
for i in user-*.pub; do {
recipients+=(-r "${i%%.pub}" --keyring "./$i")
} done
date_log "Encrypt+Sign"
ulimit -n 65535
mkdir -pm700 tmp
touch tmp/gpg.conf
gpg -se --homedir ./tmp/ --options ./tmp/gpg.conf --batch --no-use-agent --personal-cipher-preferences AES256 --personal-digest-preferences SHA512 ${recipients[*]} --passphrase changeit plain.data
#gpg -se --batch --no-use-agent --personal-cipher-preferences AES256 --personal-digest-preferences SHA512 ${recipients[*]} --passphrase changeit --secret-keyring ./user.sec --keyring ./user.pub plain.data
date_log "End"
#!/bin/bash
name=${name:-user}
gpg --batch --gen-key <<END
Key-Type: RSA
Key-Length: 2048
Name-Real: ${name}
Subkey-Type: RSA
Subkey-Length: 2048
Expire-Date: 5y
Passphrase: changeit
%pubring ${name}.pub
%secring ${name}.sec
%commit
%echo done
END
gpg --list-sigs --keyring ./${name}.pub
#!/bin/bash
cp -a ./user.pub ./pubring.gpg
gpg --batch --primary-keyring ./pubring.gpg --import ./user-*.pub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment