ubuntu - Apt 在 Ubuntu 18.04 上拒绝 `/etc/apt/trusted.gpg.d` 中的 key 环

标签 ubuntu gnupg apt ubuntu-18.04

我在 Ubuntu 18.04 (Bionic Beaver) 上遇到了一个问题,apt 以及它处理受信任 key 以验证存储库的方式。

在 Ubuntu 14.04 上,我们曾经安装用于将我们软件版本的存储库签名为 key 环的 key /etc/apt/trusted.gpg.d .通过这个 apt 知道 key 是可信的。

但是,这在 Ubuntu 18.04 上似乎不再适用。如果我在那里做同样的事情,我会在更新过程中收到错误:

# apt-get update
Hit:1 http://company.com/ubuntu-snapshot bionic InRelease                     
Reading package lists... Done                                                     
W: http://company.com/ubuntu-snapshot/dists/bionic/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/company-keys.gpg are ignored as the file is not readable by user '_apt' executing apt-key.

明显的尝试修复它
# sudo chown -v _apt /etc/apt/trusted.gpg.d/company-keys.gpg
changed ownership of '/etc/apt/trusted.gpg.d/company-keys.gpg' from root to _apt

不起作用,如 apt-get update然后产生:
# apt-get update
Hit:1 http://company.com/ubuntu-snapshot bionic     InRelease                    
Reading package lists... Done                                                     
W: http://company.com/ubuntu-snapshot/dists/bionic/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/company-keys.gpg are ignored as the file has an unsupported filetype.

key 本身是有效的,如果我使用以下行添加它,一切都会按预期进行:
 wget -O - http://company.com/key.gpg | sudo apt-key add -

不幸的是,后者不是我们的选择,因为我们想要部署我们自己的 key 并且还能够更改/撤销它们。

我不明白为什么 apt 会拒绝 /etc/apt/trusted.gpg.d 中的 key 圈,我也找不到描述 apt 对新 Ubuntu 版本的不同期望的更新日志。如果您指出一些资源来解决这个问题,我会很高兴。

最佳答案

tl;博士: Mark's answer是对的。您可以使用以下方法将 key 箱转换为 key 环:

gpg --no-default-keyring --keyring ./the-keybox-file.gpg --export > /etc/apt/trusted.gpg.d/this-keyring-will-actually-work.gpg

(更详细地描述了我遇到的问题以及我是如何解决的:)

我在尝试遵循 fluentd 安装说明的修改版本时遇到了同样的情况,这样我就不必运行 apt-key在任何服务器上。我想出了如何解决它;这是我的笔记:

我正在阅读的说明:https://docs.fluentd.org/installation/install-by-deb

他们要求您运行的脚本包括以下命令:
curl https://packages.treasuredata.com/GPG-KEY-td-agent | apt-key add -

但是我想将 key 转换为 key 环,这样我就可以将它放在一个目录中,而不是在每个服务器上运行一个命令。

我使用了一些我不久前写的类似的笔记:
  • https://unix.stackexchange.com/q/467639/135943

  • 那时我遇到了你在这里说明的问题。

    这是我使用的完整解决方案:
    # head -n 2 /etc/os-release
    NAME="Ubuntu"
    VERSION="18.04.2 LTS (Bionic Beaver)"
    # ls
    GPG-KEY-td-agent
    # file GPG-KEY-td-agent
    GPG-KEY-td-agent: PGP public key block Public-Key (old)
    # gpg --no-default-keyring --keyring ./tempfile.gpg --import ./GPG-KEY-td-agent
    gpg: keybox './tempfile.gpg' created
    gpg: key 901F9177AB97ACBE: public key "Treasure Data, Inc (Treasure Agent Official Signing key) <support@treasure-data.com>" imported
    gpg: Total number processed: 1
    gpg:               imported: 1
    # gpg --no-default-keyring --keyring ./tempfile.gpg --export > td-agent-keyring.gpg
    # file *
    GPG-KEY-td-agent:     PGP public key block Public-Key (old)
    td-agent-keyring.gpg: GPG key public ring, created Tue Dec 27 08:18:20 2016
    tempfile.gpg:         GPG keybox database version 1, created-at Sat Jul 20 02:36:45 2019, last-maintained Sat Jul 20 02:36:45 2019
    tempfile.gpg~:        GPG keybox database version 1, created-at Sat Jul 20 02:36:45 2019, last-maintained Sat Jul 20 02:36:45 2019
    # mv td-agent-keyring.gpg /etc/apt/trusted.gpg.d/
    # 
    

    关于ubuntu - Apt 在 Ubuntu 18.04 上拒绝 `/etc/apt/trusted.gpg.d` 中的 key 环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51300627/

    相关文章:

    python - Errno - 13 权限被拒绝 : '/media/- Django

    c++ - 无法编译 Intel Pin

    ubuntu - start-dfs.sh 抛出端口 22 : connection timeout error

    key - 无法从 keys.gnupg.net 添加 key

    bash - 解析 GnuPG key 列表

    Bash 脚本被打印而不是被执行

    ruby-on-rails - 是什么导致私有(private)方法 `gsub` 调用 nil :NilClass during Rails migration?

    java - 如何使用 Java 解密字符串被 gpg 加密的字符串?

    python - 如何用打包版本替换从源安装的 Python?

    ubuntu - apt-get 安装中使用的 -y 标志是什么?