Você pode transferir a chave "manualmente" da seguinte maneira, sem tentar descriptografá-la:
# create temporary destination dir
mkdir -m 700 /tmp/alt-gnupg
# transfer public keys using export/import, assuming name "user-000"
gpg2 --export user-000 | gpg2 --homedir /tmp/alt-gnupg --import
# transfer private keys using file copy
for g in $(gpg2 --list-keys --with-keygrip --with-colons 'user-000' |
awk -F: '$1=="grp" {print $10}'); do
cp ~/.gnupg/private-keys-v1.d/$g.key /tmp/alt-gnupg/private-keys-v1.d
done
# check you got them
gpg2 --homedir /tmp/alt-gnupg --list-secret-keys
Isso funciona porque as chaves privadas são armazenadas em arquivos no formato <keygrip>.key
e podemos encontrar os keygrips sem destravar.
Para forçar as chaves:
# use alternate gnupg dir
export GNUPGHOME=/tmp/alt-gnupg
# create dummy encrypted file
echo hello |
gpg2 --encrypt --recipient user-000 --armor >/tmp/msg.asc
# tell gpg-agent to accept loopback pinentry
echo allow-loopback-pinentry >${GNUPGHOME}/gpg-agent.conf
# restart gpg-agent
gpg-connect-agent /bye
# and now...
for p in pass1 pass2; do
gpg2 --batch --pinentry-mode=loopback --passphrase "$p" --quiet --decrypt /tmp/msg.asc >/dev/null 2>&1 && echo "yes!! pass: $p"
done