Consulte o link . Tratar o arquivo-chave como um chaveiro não funcionou para mim, mas a resposta aceita ajudou.
cat keyfile.key | gpg --with-colons --import-options import-show --dry-run --import
Testado no Debian 9 com gpg 2.1.18 e Fedora 26 com gpg2 2.2.0:
$ gpg2 --with-fingerprint --import-options import-show --dry-run --import < linux_signing_key.pub
pub dsa1024 2007-03-08 [SC]
4CCA 1EAF 950C EE4A B839 76DC A040 830F 7FAC 5991
uid Google, Inc. Linux Package Signing Key <[email protected]>
sub elg2048 2007-03-08 [E]
pub rsa4096 2016-04-12 [SC]
EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796
uid Google Inc. (Linux Packages Signing Authority) <[email protected]>
sub rsa4096 2016-04-12 [S] [expires: 2019-04-12]
gpg: Total number processed: 2
Também é possível que --with-fingerprints
esteja obsoleto. O GPG2 parece ter sido corrigido para interromper a saída dos ids de chave curta inseguros.
$ gpg2 --import-options import-show --dry-run --import < linux_signing_key.pub pub dsa1024 2007-03-08 [SC]
4CCA1EAF950CEE4AB83976DCA040830F7FAC5991
4CCA1EAF950CEE4AB83976DCA040830F7FAC5991
uid Google, Inc. Linux Package Signing Key <[email protected]>
sub elg2048 2007-03-08 [E]
pub rsa4096 2016-04-12 [SC]
EB4C1BFD4F042F6DDDCCEC917721F63BD38B4796
EB4C1BFD4F042F6DDDCCEC917721F63BD38B4796
uid Google Inc. (Linux Packages Signing Authority) <[email protected]>
sub rsa4096 2016-04-12 [S] [expires: 2019-04-12]
gpg: Total number processed: 2
Infelizmente, eu queria uma saída legível por máquina de --with-colons
, mas há algo mais acontecendo lá: - (.
$ gpg --with-colons --with-fingerprint --import-options import-show --dry-run --import < linux_signing_key.pub
gpg: lookup_hashtable failed: Unknown system error
gpg: trustdb: searching trust record failed: Unknown system error
gpg: Error: The trustdb is corrupted.
gpg: You may try to re-create the trustdb using the commands:
gpg: cd ~/.gnupg
gpg: gpg --export-ownertrust > otrust.tmp
gpg: rm trustdb.gpg
gpg: gpg --import-ownertrust < otrust.tmp
gpg: If that does not work, please consult the manual
Acabei usando o seguinte código
gpg_show_fingerprints() {
gpg2 --with-fingerprint --import-options import-show --dry-run --import < "$1" >/dev/null 2>&1
if [ "$?" == 2 ]; then
# Usage error. Try the old way.
gpg2 --with-fingerprint "$1"
else
gpg2 --with-fingerprint --import-options import-show --dry-run --import < "$1"
fi
}
gpg_show_fingerprints "$1" |
sed -E -n -e 's/.*(([0-9A-F]{4}[ ]*){10,}).*// p'