Last active
July 8, 2020 21:05
-
-
Save kalw/1ed9c2c2be5558b8ceddd43c5682bf28 to your computer and use it in GitHub Desktop.
headless gpg gitcrypt passphrase tests
This file contains hidden or 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
#docker run --rm -ti alpine:3.11.6 sh | |
apk update | |
apk add -U git-crypt gnupg | |
export GPG_PRIV=$(cat /cat/to/priv.key) | |
export GPG_PUB=$(cat /path/to/pub.key) | |
export GPG_PASSPHRASE="myPassphrase" | |
export GPG_KEYID=$(echo "${GPG_PUB}" | gpg --with-colons --import-options show-only --import |grep pub |awk -F':' '{print $5}') | |
export GPG_EMAIL=$(echo "${GPG_PUB}" | gpg --with-colons --import-options show-only --import |grep uid| awk -F:: '{print $5}'| grep -o -e '<.*>' |sed -e 's/[<>]*//g') | |
export GPG_NAME=$(echo "${GPG_PUB}" | gpg --with-colons --import-options show-only --import |grep uid| awk -F:: '{print $5}' |awk -F'<' '{print $1}') | |
git config --global user.email "${GPG_EMAIL}" | |
git config --global user.name "${GPG_NAME}" | |
gpgconf --kill gpg-agent | |
gpg-agent --daemon --allow-preset-passphrase --max-cache-ttl 3153600000 --default-cache-ttl 60480000 --allow-loopback-pinentry | |
echo "${GPG_PRIV}${GPG_PUB}" | gpg --import --passphrase "${GPG_PASSPHRASE}" --pinentry-mode loopback | |
echo -e "5\ny\n" | gpg --command-fd 0 --edit-key ${GPG_EMAIL} trust quit | |
# input programatically passphrase and caching it | |
echo "test" > test.clear | |
echo ${GPG_PASSPHRASE} | gpg --batch --no-tty --pinentry-mode loopback --passphrase-fd 0 -e -r ${GPG_EMAIL} test.clear | |
echo ${GPG_PASSPHRASE} | gpg --batch --no-tty --pinentry-mode loopback --passphrase-fd 0 -d test.clear.gpg | |
mkdir repo | |
cd repo | |
git init | |
git crypt init | |
git-crypt add-gpg-user --trusted ${GPG_EMAIL} | |
git crypt unlock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment