# gpg --list-keys /root/.gnupg/pubring.gpg ------------------------ pub 1024D/2D230C5F 2006-01-03 [expired: 2007-02-07] uid Debian Archive Automatic Signing Key (2006) <ftpmaster@debian.org> pub 1024D/7610DDDE 2006-03-03 [revoked: 2016-03-31] uid Archive Maintainer <root@xxxxxxxxxx.com> pub 4096R/DD219672 2016-04-18 uid Archive Maintainer <root@xxxxxxxxxx.com>
以下所有命令均为root用户.
我修改了repository / conf / distributions文件以使用我明确创建的新子密钥进行签名:
Architectures: i386 amd64 source Codename: unstable Components: main ... SignWith: DD219672
但是当我使用dput来更新包时,我得到了
Could not find any key matching 'DD219672'! ERROR: Could not finish exporting 'unstable'! This means that from outside your repository will still look like before (and should still work if this old state worked),but the changes intended with this call will not be visible until you call export directly (via reprepro export)
当我直接运行reprepro export时,我得到:
# reprepro -V export unstable Exporting unstable... generating main/Contents-i386... generating main/Contents-amd64... Could not find any key matching 'DD219672'! ERROR: Could not finish exporting 'unstable'!
我用Google搜索并发现了几个旧线程,表明可能有问题,找到正确的gnupg目录…所以我尝试了上面相同的结果:
# GNUPGHOME=/root/.gnupg reprepro -V export unstable
一个线程建议通过签署一个似乎工作正常的虚拟文件来测试密钥……至少它报告没有错误,并且在完成后我得到了一个576字节的bla.gpg文件.
# touch bla # gpg -u DD219672 --sign bla
reprepro手册页还建议“如果签名有问题,你可以尝试gpg –list-secret-keys值来看看gpg如何解释这个值.如果那个命令没有列出任何键或多个键,试着找其他一些价值(比如keyid),gpg可以更容易地与一个唯一的密钥相关联.“所以我也检查了一下,得到了:
# gpg --list-secret-keys DD219672 sec 4096R/DD219672 2016-04-18 uid Archive Maintainer <root@xxxxxxxxxx.com>
最后,我能够与首先设置我们的repros的系统管理员取得联系,他建议尝试一个没有密码短语的密钥.所以我生成了一个新的签名密钥DD219672,发布了它,再次执行了上述步骤但结果相同.
今天,在更多阅读和学习手册之后,注意到当我运行reprepro时pgp-agent自动启动时,我决定追了一会儿.
我添加了一个gpg-agent.conf
debug-level 7 log-file /root/gpg.agent.log debug-all
我可以在日志中看到gpg-agent没有找到密钥
2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> OK Pleased to meet you,process 18903 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- RESET 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> OK 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- OPTION ttyname=/dev/pts/0 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> OK 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- OPTION ttytype=xterm-256color 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> OK 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- GETINFO version 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> D 2.1.11 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> OK 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- OPTION allow-pinentry-notify 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> OK 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- OPTION agent-awareness=2.1.0 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> OK 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- AGENT_ID 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> ERR 67109139 Unknown IPC command <GPG Agent> 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- HAVEKEY C2C5C59E5E90830F314ABB66997CCFAACC5DEA2F 416E8A33354912FF4843D52AAAD43FBF206252D9 8CE77065EA6F3818A4975072C8341F32CB7B0EF0 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 -> ERR 67108881 No secret key <GPG Agent> 2016-04-18 15:54:00 gpg-agent[15582] DBG: chan_5 <- [eof]
到目前为止,我还无法弄清楚gpg-agent在HAVKEY中找到它所列出的密钥,以及如何指向正确的方向找到新密钥DD219672以签署我们更新的软件包.
解决方法
reprepro工具使用gpgme,它基于gnupg2.最近的一个版本改变了秘密密钥环的处理方式:https://www.gnupg.org/faq/whats-new-in-2.1.html
gpg used to keep the public key pairs in two files:
pubring.gpg
and
secring.gpg
… With GnuPG 2.1 this changed … To ease the
migration to the no-secring method,gpg detects the presence of a
secring.gpg
and converts the keys on-the-fly to the the key store of
gpg-agent (this is theprivate-keys-v1.d
directory below the GnuPG
home directory (~/.gnupg
)). This is done only once and an existing
secring.gpg
is then not anymore touched by gpg. This allows
co-existence of older GnuPG versions with GnuPG 2.1. However,any
change to the private keys using the new gpg will not show up when
using pre-2.1 versions of GnuPG and vice versa.
因此,如果您使用gpg创建新密钥,gpg2将无法看到它,反之亦然.
快速修复对我有用:
gpg --export-secret-keys | gpg2 --import -
如果你需要走另一条路,当然:
gpg2 --export-secret-keys | gpg --import -
根据您的设置,您可能还需要/需要添加–export-secret-subkeys
完成上述操作后,reprepro使用我的新密钥正常工作.