Linux

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > Linux > CentOS7.6 yum报错GPG密钥不匹配:GPG Keys are configured as:https://mirrors.aliyun.com/centos/...

解决CentOS7.6 yum报错GPG密钥不匹配:GPG Keys are configured as:https://mirrors.aliyun.com/centos/...问题

作者:MicroLindb

文章主要讲述了在使用yum安装`devtoolset-8-gcc*`时遇到GPG密钥不匹配的问题,并提供了两种解决方法:一是检查并修正.repo文件中的GPG密钥设置,二是同时保留阿里云和CentOS官方的GPG密钥,最终成功安装了gcc

一、报错

1.报错内容

执行 yum install -y devtoolset-8-gcc* 报错

[root@hcss-ecs-a901 make-4.3] yum install -y devtoolset-8-gcc*

省略...
Transaction Summary
======================================================================================================
Install  5 Packages (+17 Dependent packages)

Total size: 67 M
Installed size: 194 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/centos-sclo-rh/packages/devtoolset-8-gcc-gdb-plugin-8.3.1-3.2.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f2ee9d55: NOKEY
Retrieving key from https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7


The GPG keys listed for the "CentOS-7 - SCLo rh" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.


 Failing package is: devtoolset-8-gcc-gdb-plugin-8.3.1-3.2.el7.x86_64
 GPG Keys are configured as: https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

2.原因

GPG密钥不匹配 或者 密钥缺失。

(一般来说,都是 .repo 文件的 gpgkey 设置错误导致的)

3.什么是 GPG 密钥?(AI 解释)

GPG(GNU Privacy Guard)密钥用于验证软件包的完整性和来源。

具体来说,它可以确保软件包在传输过程中没有被篡改,并且确实是由合法的发布者创建的。

GPG 密钥分为公钥和私钥两部分:

在使用 yum 安装软件包时,系统会使用 GPG 公钥来验证软件包的签名,以确保软件包的安全性。

二、解决

1.问问GPT

2.改进版本的解决方案

2.1 运行命令:

vi /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

2.2 替换文件内容如下(请别直接抄,把 gpgkey 的 URL 换成你需要的 URL)

# CentOS-SCLo-rh.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-rh]
name=CentOS-$releasever - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7,https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-SCLo

2.3 引入 GPGKEY

rpm --import https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
rpm --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-SCLo

2.4 重新安装(我装我的gcc,你装你的软件去)

yum install -y devtoolset-8-gcc*

三、解决

gcc安装成功了

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文