在 ubuntu 20.04 中设置或更改首选 gpg 密钥服务器的正确方法?

在 ubuntu 20.04 中设置或更改首选 gpg 密钥服务器的正确方法?

我正在使用 ubuntu 服务器 20.04。我正尝试从密钥服务器下载开发人员公共 gpg/pgp 密钥。对于我想要的许多密钥,它们似乎没有列在 ubuntu 的默认密钥服务器上。列出的密钥似乎不准确,或者似乎已过时或过期。我想要做的是,当尝试在 ubuntu 上下载公钥时,让 ubuntu 默认从最严格(电子邮件要求方面)的密钥服务器 (https://keys.openpgp.org/),然后,如果未找到,则自动从更宽松、更兼容的密钥服务器 (hkp://pool.sks-keyservers.net) 中查找密钥。

我遇到的第一个问题是,在终端中找不到 ubuntu 在进行密钥查找/下载时存储其默认永久密钥服务器地址的任何设置。因此,我的问题是:

  1. 默认的 ubuntu 密钥服务器设置位于哪里(我可以修改哪个文件来永久更改 ubuntu 中的默认密钥服务器?)?
  2. 我如何设置 2 个密钥服务器(在 ubuntu 中),它们的顺序是 ubuntu 向它们发出请求的偏好?例如 keyserver1=https://keys.openpgp.org/ 和 keyserver2=hkp://pool.sks-keyservers.net,这样如果在 keyserver1 上找不到密钥,ubuntu 就会在 keyserver2 上搜索密钥?

谢谢你的帮助!

答案1

默认的 ubuntu 密钥服务器设置位于哪里(我可以修改哪个文件来永久更改 ubuntu 中的默认密钥服务器?)?

默认情况下,它位于 中~/.gnupg/gpg.conf。如果您没有此文件/目录,您可以调用gpg --version来查看 GPG 副本的配置存储位置。

我如何设置 2 个密钥服务器(在 ubuntu 中),它们的顺序是 ubuntu 向它们发出请求的偏好?例如 keyserver1=https://keys.openpgp.org/ 和 keyserver2=hkp://pool.sks-keyservers.net,这样如果在 keyserver1 上找不到密钥,ubuntu 就会在 keyserver2 上搜索密钥?

在配置文件中,其中包含注释形式的说明,您将发现以下内容:

> # GnuPG can automatically locate and retrieve keys as needed using the
> # auto-key-locate option.  This happens when encrypting to an email
> # address (in the "[email protected]" form), and there are no
> # [email protected] keys on the local keyring.  This option takes the
> # following arguments, in the order they are to be tried:
> # 
> # cert = locate a key using DNS CERT, as specified in RFC-4398.
> #        GnuPG can handle both the PGP (key) and IPGP (URL + fingerprint)
> #        CERT methods.
> #
> # pka = locate a key using DNS PKA.
> #
> # ldap = locate a key using the PGP Universal method of checking
> #        "ldap://keys.(thedomain)".  For example, encrypting to
> #        [email protected] will check ldap://keys.example.com.
> #
> # keyserver = locate a key using whatever keyserver is defined using
> #             the keyserver option.
> #
> # You may also list arbitrary keyservers here by URL.

相关部分是第五行:“按照审判顺序”

答案2

不幸的是,我找不到我的 gpg.conf 文件。因此,为了获得强化的 gpg 配置文件,我从 Dr.Duh 的 github 页面下载了一个强化的 gpg.conf 文件,网址为github.com/drduh/config/blob/master/gpg.conf

然后我对其进行了修改,使其包含我想要的密钥服务器,按照我希望 Mac OS 读取它们的顺序,密钥服务器在顶部,是 macOS 读取的第一个密钥服务器。

相关内容