【问题标题】:How to automate installation of missing GPG keys on Linux如何在 Linux 上自动安装缺少的 GPG 密钥
【发布时间】:2021-11-09 10:45:16
【问题描述】:

我使用 Linux 容器已经有好几年了。我很惊讶我找不到关于这个问题的线索。场景:

我刚刚添加了一个新的包索引 (/etc/sources.list.d/example.list) 并想安装一个包,我们称之为 snailmail。

我运行命令:

apt-get update && apt-get install -y snailmail

我收到以下错误:

W: GPG error: https://example.com/snailmail/debian stable InRelease:
The following signatures couldn't be verified because the public key is not available:
NO_PUBKEY 7EF2A9D5F293ECE4

自动安装 GPG 密钥的最佳方法是什么?

【问题讨论】:

    标签: linux docker containers gnupg apt


    【解决方案1】:

    这是一个方便的脚本,可以在构建过程中调用以下载和安装通用 GPG 密钥(来自 Ubuntu 密钥服务器):

    先决条件:

    • wget
    for PUBKEY in $(apt-get update 2>&1 | grep NO_PUBKEY | awk '{print $NF}')
    do
     wget -q "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x${PUBKEY}" -O - | sed -n '/BEGIN/,/END/p' | apt-key add - 2>/dev/null
    done
    

    【讨论】:

      猜你喜欢
      • 2018-11-10
      • 1970-01-01
      • 2014-10-09
      • 1970-01-01
      • 2016-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-28
      相关资源
      最近更新 更多