39 lines
758 B
Bash
Executable File
39 lines
758 B
Bash
Executable File
#!/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
|
|
keyserver-options auto-key-retrieve
|
|
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
|