38 lines
722 B
Bash
38 lines
722 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Go to home directory for sure
|
||
|
pushd $HOME >/dev/null
|
||
|
|
||
|
# Kill gpg-agent
|
||
|
pkill gpg-agent
|
||
|
|
||
|
# Rewrite gpg-agent configuration
|
||
|
cat > ~/.gnupg/gpg-agent.conf <<EOF
|
||
|
default-cache-ttl 4320000
|
||
|
max-cache-ttl 8640000
|
||
|
allow-loopback-pinentry
|
||
|
EOF
|
||
|
|
||
|
# Start gpg-agent
|
||
|
gpg-agent
|
||
|
|
||
|
|
||
|
# Create dummy file
|
||
|
_dummyfile=`mktemp`
|
||
|
echo "foobar" > "${_dummyfile}"
|
||
|
|
||
|
# Cache password in gpg-agent by signing dummy file
|
||
|
cat ~/passphrase.txt | env -i gpg \
|
||
|
--pinentry-mode loopback --passphrase-fd 0 \
|
||
|
--no-tty --batch --yes \
|
||
|
--detach-sig --output "${_dummyfile}.sig" "${_dummyfile}"
|
||
|
|
||
|
# Verify given signature
|
||
|
env -i gpg --verify \
|
||
|
"${_dummyfile}.sig" "${_dummyfile}"
|
||
|
|
||
|
echo $?
|
||
|
|
||
|
rm "${_dummyfile}" "${_dummyfile}.sig"
|
||
|
popd >/dev/null
|