Skip to content

Instantly share code, notes, and snippets.

@alexander-bauer
Created May 3, 2013 20:53
Show Gist options
  • Save alexander-bauer/5514034 to your computer and use it in GitHub Desktop.
Save alexander-bauer/5514034 to your computer and use it in GitHub Desktop.
This script uses simple utilities to download a GPG public key over http and import it to the keyring.
#!/bin/bash
## downloadkey.sh
##
## © 2013 Alexander Bauer, released under GPL-3+
## The full text of GPL-3 can be found in /usr/share/common-licenses
##
#
# This script uses simple utilities to download a GPG public key over
# http and import it to the keyring.
#
if [ -z "$1" ]; then
echo "No URL provided."
exit 1
fi
URL=$1
DOWNLOADCMD="wget --quiet --output-document=-"
AWKCMD="awk"
GPGIMPORTCMD="gpg --import"
$DOWNLOADCMD $URL | $AWKCMD '$0 == "-----BEGIN PGP PUBLIC KEY BLOCK-----" { INKEY=1 }; INKEY; $0 == "-----END PGP PUBLIC KEY BLOCK-----" { exit 0; }' - | $GPGIMPORTCMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment