错误:为仓库 'gitlab_gitlab-ce' 下载元数据失败 : repomd.xml GPG signature verification error: Bad GPG signature

解决办法:https://docs.gitlab.com/omnibus/update/package_signatures.html#update-keys-after-expiry-extension

操作步骤

对于基于 Debian 的发行版:

一、确定您是否正在使用apt-key或signed-by功能(Centos系统请忽略):

grep 'deb \[signed-by=' /etc/apt/sources.list.d/gitlab_gitlab-?e.list
  • 如果这grep返回任何行,则您正在使用signed-by功能。这优先于任何apt-key用法。
  • 如果这grep没有返回任何行,那么您正在使用apt-key功能。

二、对于signed-by,以下脚本(以 root 身份运行)更新 GitLab 存储库的公钥(Centos系统请忽略):

   awk '/deb \[signed-by=/{
       pubkey = $2;
       sub(/\[signed-by=/, "", pubkey);
       sub(/\]$/, "", pubkey);
       print pubkey
     }' /etc/apt/sources.list.d/gitlab_gitlab-?e.list | \
   while read line; do
     curl -s "https://packages.gitlab.com/gpg.key" | gpg --dearmor > $line
   done

三、对于apt-key,以下脚本(以 root 身份运行)更新 GitLab 存储库的公钥(Centos系统请忽略):

 apt-key del 3F01618A51312F3F
 curl -s "https://packages.gitlab.com/gpg.key" | apt-key add -
 apt-key list 3F01618A51312F3F

对于基于 RPM 的发行版(CentOS按照此方法操作):

一、从存储库密钥环中删除任何现有密钥(创建一个.sh可执行文件粘贴以下内容):

for pubring in /var/cache/dnf/gitlab_gitlab-?e-*/pubring
 do
   gpg --homedir $pubring --delete-key F6403F6544A38863DAA0B6E03F01618A51312F3F
 done

然后执行该文件
sh 文件名.sh

一直按y直到全部删除

二、更新存储库数据/缓存,要求您确认密钥:

dnf check-update

要获取最新的存储库签名密钥,用户可以再次运行curl用于添加 GitLab 存储库的命令,如安装页面中所述。它将获取新密钥并将其添加到用户的密钥环中。
或者,用户可以使用以下命令手动获取并添加新密钥

 # Download the new key
 curl "https://packages.gitlab.com/gpg.key" -o /tmp/omnibus_gitlab_gpg.key

 # Import the key
 ## Debian/Ubuntu/Raspbian
 sudo apt-key add /tmp/omnibus_gitlab_gpg.key

 # CentOS/OpenSUSE/SLES
 sudo rpm --import /tmp/omnibus_gitlab_gpg.key

注意:apt-key是debian等系统的命令在centos系统中执行无效

posted @ 2022-09-14 11:08  张双健  阅读(1338)  评论(0编辑  收藏  举报