38

我从23.1到23.3只用了半年的emacs。

每次我试图找到 emacs 的 gpg 公钥以便我可以检查 tar.gz 包和每个新版本发布的 tar.gz.sig 时,我都失败了。

看来我应该先获取公钥,我搜索了emacs的网站,但没有找到标志......

我只能在邮件列表 http://lists.gnu.org/archive/html/info-gnu-emacs/2011-03/msg00000.html中找到 SHA1 校验和来进行完整性检查

我该怎么做呢?

4

4 回答 4

40

如果您尝试使用验证签名

gpg --verify <pkg>.key

您将获得如下输出:

gpg: Signature made 02/17/05 14:02:42 GTB Standard Time using DSA key ID BE216115
gpg: Can't check signature: No public key

您要查找的密钥 ID 是BE216115,因此您要求 gpg 使用以下命令检索它:

gpg --recv-keys BE216115

这导致我的安装如下:

gpg: requesting key BE216115 from hkp server keys.gnupg.net
gpg: key BE216115: public key "Francesco Potortì <pot@potorti.it>" imported
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   1  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: depth: 1  valid:   1  signed:   6  trust: 0-, 0q, 0n, 0m, 1f, 0u
gpg: depth: 2  valid:   6  signed:   1  trust: 0-, 0q, 0n, 6m, 0f, 0u
gpg: Total number processed: 1
gpg:               imported: 1

现在,您可以验证它。但是由于您没有为此密钥分配任何信任,因此输出将是:

gpg: Signature made 02/17/05 14:02:42 GTB Standard Time using DSA key ID BE216115
gpg: Good signature from "Francesco Potortì <pot@potorti.it>"
gpg:                 aka "Francesco Potortì <pot@gnu.org>"
gpg:                 aka "Francesco Potortì <Potorti@isti.cnr.it>"
gpg:                 aka "Francesco Potortì <pot@softwarelibero.it>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 4B02 6187 5C03 D6B1 2E31  7666 09DF 2DC9 BE21 6115

因此,您将知道签名是有效的,但您不信任公钥。您可以使用以下方式信任或签署公钥:

gpg --edit-key BE216115

在命令提示符下键入help以查看所有可用选项。有关详细信息,请参阅使用 GNU 隐私保护

于 2011-04-18T10:40:34.487 回答
29

GNU 密钥环位于https://ftp.gnu.org/gnu/gnu-keyring.gpg

您可以在本地(下载后)导入它们

gpg --import gnu-keyring.gpg
于 2011-04-19T02:17:12.447 回答
15

@vhallac 的答案现在已经过时了(我正在尝试验证 emacs-24.4 下载)。如果您不想下载和导入整个 GNU 密钥环(如 @JSON 所讨论的那样),这里有一种方法可以完成此操作。在这个答案中,我将展示今天有效的方法,以及如何找出一年后有效的方法。

首先下载 emacs 及其.sig文件。我有:

$ ls | grep emacs
emacs-24.4.tar.xz
emacs-24.4.tar.xz.sig

假设您已经安装了 gpg,请尝试验证它:

$ gpg --verify emacs-24.4.tar.xz.sig 
gpg: Signature made Mon 20 Oct 2014 02:58:21 PM EDT using RSA key ID A0B0F199
gpg: Can't check signature: public key not found

在此尝试中,它失败了(您将在本文末尾看到成功的尝试)。我没有公钥。输出告诉您需要获取哪个公钥: A0B0F199. (这是将来最有可能改变的事情。)

所以我然后尝试使用默认命令下载它:

$ gpg --recv-keys A0B0F199
gpg: requesting key A0B0F199 from hkp server keys.gnupg.net
(...hangs here...)

它只是挂起。那是因为我ufw(我的 Linux 防火墙软件)阻止了大多数端口。您可以告诉 gpg 使用端口 80,如下所示:

$ gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys A0B0F199
gpg: requesting key A0B0F199 from hkp server keys.gnupg.net
gpgkeys: key A0B0F199 not found on keyserver
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

它通过了防火墙,但由于某种原因,Emacs/FSF 密钥不再存储在 gnupg 服务器上,所以失败了。所以我尝试了另一个我知道并有一定程度信任的密钥服务器:

$ gpg --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys A0B0F199
gpg: requesting key A0B0F199 from hkp server pool.sks-keyservers.net
gpg: key A0B0F199: public key "Glenn Morris <rgm@gnu.org>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

好的,它奏效了。现在检查一下:

$ gpg --list-keys
...
pub   2048R/A0B0F199 2012-12-23 [expires: 2015-12-23]
uid                  Glenn Morris <rgm@gnu.org>
sub   2048R/951C59EC 2012-12-23 [expires: 2015-12-23]

是的,明白了。

现在我可以验证下载的 emacs tarball:

$ gpg --verify emacs-24.4.tar.xz.sig 
gpg: Signature made Mon 20 Oct 2014 02:58:21 PM EDT using RSA key ID A0B0F199
gpg: Good signature from "Glenn Morris <rgm@gnu.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: B294 26DE FB07 724C 3C35  E5D3 6592 E9A3 A0B0 F199

签名是“好”,但不受信任。请参阅其他答案以了解如何信任该密钥。

于 2015-03-07T18:07:35.407 回答
14

在 GNU FTP 服务器的根级别有一个README文件,它解释了如何使用签名。

有关最新版本,请参阅https://ftp.gnu.org/README 。

当前文件说:

There are also .sig files, which contain detached GPG signatures of the above
files, automatically signed by the same script that generates them.

You can verify the signatures for gnu project files with the keyring file from:
  https://ftp.gnu.org/gnu/gnu-keyring.gpg

In a directory with the keyring file, the source file to verify and the
signature file, the command to use is:

  $ gpg --verify --keyring ./gnu-keyring.gpg foo.tar.xz.sig
于 2015-03-08T12:37:38.420 回答