Yum

在添加 Kubernetes 儲存庫時,即使在“rpm –import”之後,Amazon Linux 2 中的 Yum 仍然要求 GPG 密鑰

  • June 30, 2019

我正在嘗試將kubernetes 儲存庫添加到我的Amazon Linux 2實例中,並且難以自動添加 GPG 密鑰。

這是我的/etc/yum.repos.d/kubernetes.repo

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
      https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

然後我嘗試導入 GPG 密鑰:


~ # wget https://packages.cloud.google.com/yum/doc/yum-key.gpg \
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

~ # rpm --import *.gpg

但是,當我執行任何yum命令時,它仍然不知道鍵:

# yum upgrade -y
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
kubernetes/signature                                                                                                                                                                                                   |  454 B  00:00:00     
Retrieving key from https://packages.cloud.google.com/yum/doc/yum-key.gpg
Importing GPG key 0xA7317B0F:
Userid     : "Google Cloud Packages Automatic Signing Key <gc-team@google.com>"
Fingerprint: d0bc 747f d8ca f711 7500 d6fa 3746 c208 a731 7b0f
From       : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Retrieving key from https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
kubernetes/signature                                                                                                                                                                                                   | 1.4 kB  00:00:00 !!! 
https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for kubernetes
Trying other mirror.
No packages marked for update

即使我嘗試手動接受它們,它仍然不起作用。

# yum upgrade
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
kubernetes/signature                                                                                                                                                                                                   |  454 B  00:00:00     
Retrieving key from https://packages.cloud.google.com/yum/doc/yum-key.gpg
Importing GPG key 0xA7317B0F:
Userid     : "Google Cloud Packages Automatic Signing Key <gc-team@google.com>"
Fingerprint: d0bc 747f d8ca f711 7500 d6fa 3746 c208 a731 7b0f
From       : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Is this ok [y/N]: y              <<<<< Yes, I accept it!
Retrieving key from https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
kubernetes/signature                                                                                                                                                                                                   | 1.4 kB  00:00:01 !!! 
https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for kubernetes
Trying other mirror.
No packages marked for update

如何添加密鑰以便 YUM 接受它?

這是一個已知問題(請參閱https://github.com/kubernetes/kubernetes/issues/60134)。通過禁用 GPG 檢查來解決它:repo_gpgcheck=0/etc/yum.repos.d/kubernetes.repo.

歸功於 drakedevel,他寫道:

我認為這是由於 Amazon Linux 2 發布了舊版本的 GnuPG,而有關 repomd.xml.asc 簽名的某些內容需要更新版本。

GnuPG 2.0.22 完全拒絕儲存庫元數據上的簽名,並假設密鑰 BA07F4FB 由於未知的關鍵位而導致簽名錯誤。我無法弄清楚它指的是什麼關鍵位——簽名或密鑰上似乎沒有任何關鍵位——但無論 GnuPG 2.0.22 對什麼感到不安,這很可能是根本原因。

這只會影響 repomd 簽名,因此像其他幾個人所建議的那樣,禁用 gpgcheck 的理由為零。禁用 repo_gpgcheck 就足夠了,並且可以保留包簽名驗證(儘管它仍然不是一個理想的解決方法……)

引用自:https://unix.stackexchange.com/questions/527707