centos中安装rpm包报错——No KEY

由于本机是刚装的centos7,默认并没有安装nc - netcat,所以下载了一个rpm包,安装时报错如下:

[cos@localhost Desktop]$ ls
netcat-0.7.1-1.i386.rpm
[cos@localhost Desktop]$ rpm -ivh netcat-0.7.1-1.i386.rpm 
警告:netcat-0.7.1-1.i386.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID b2d79fc1: NOKEY
错误:依赖检测失败:
    libc.so.6 被 netcat-0.7.1-1.i386 需要
    libc.so.6(GLIBC_2.0) 被 netcat-0.7.1-1.i386 需要
    libc.so.6(GLIBC_2.1) 被 netcat-0.7.1-1.i386 需要
    libc.so.6(GLIBC_2.3) 被 netcat-0.7.1-1.i386 需要

原来需要centos 的 GPG key

 http://centos.ustc.edu.cn/centos/7/os/x86_64/ 中找到相应的GPG key下载并导入即可解决问题。(本机为:RPM-GPG-KEY-CentOS-7)

然后用gpg命令导入即可:

[cos@localhost Desktop]$ gpg --quiet --with-fingerprint ./RPM-GPG-KEY-CentOS-7 
gpg: 新的配置文件‘/home/cos/.gnupg/gpg.conf’已建立
gpg: 警告:在‘/home/cos/.gnupg/gpg.conf’里的选项于此次运行期间未被使用
pub  4096R/F4A80EB5 2014-06-23 CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>
密钥指纹 = 6341 AB27 53D7 8A78 A7C2  7BB1 24C6 A8A7 F4A8 0EB5

再次导入netcat的rpm包即可成功:

[cos@localhost Desktop]$ rpm netcat-0.7.1-1.i386.rpm 
RPM 版本 4.11.1
版权所有 (C) 1998-2002 - 红帽公司。
该程序可以在 GNU GPL 条款下自由分发

用法: rpm [-aKfgpqVcdLilsiv?] [-a|--all] [-f|--file] [-g|--group]
        [-p|--package] [--pkgid] [--hdrid] [--triggeredby] [--whatrequires]
        [--whatprovides] [--nomanifest] [-c|--configfiles] [-d|--docfiles]
        [-L|--licensefiles] [--dump] [-l|--list] [--queryformat=QUERYFORMAT]
        [-s|--state] [--nofiledigest] [--nofiles] [--nodeps] [--noscript]
        [--allfiles] [--allmatches] [--badreloc] [-e|--erase <package>+]
        [--excludedocs] [--excludepath=<path>] [--force]
        [-F|--freshen <packagefile>+] [-h|--hash] [--ignorearch] [--ignoreos]
        [--ignoresize] [-i|--install] [--justdb] [--nodeps] [--nofiledigest]
        [--nocontexts] [--noorder] [--noscripts] [--notriggers]
        [--nocollections] [--oldpackage] [--percent] [--prefix=<dir>]
        [--relocate=<old>=<new>] [--replacefiles] [--replacepkgs] [--test]
        [-U|--upgrade <packagefile>+] [-D|--define “MACRO EXPR”]
        [--undefine=MACRO] [-E|--eval “EXPR”] [--macros=<FILE:…>]
        [--nodigest] [--nosignature] [--rcfile=<FILE:…>] [-r|--root ROOT]
        [--dbpath=DIRECTORY] [--querytags] [--showrc] [--quiet]
        [-v|--verbose] [--version] [-?|--help] [--usage] [--scripts]
        [--setperms] [--setugids] [--conflicts] [--obsoletes] [--provides]
        [--requires] [--info] [--changelog] [--xml] [--triggers] [--last]
        [--dupes] [--filesbypkg] [--fileclass] [--filecolor] [--fscontext]
        [--fileprovide] [--filerequire] [--filecaps]

如果你遇到该问题,按照如上方法,希望可以解决你的问题。注意:系统版本以及GPG Key文件要选择对应的。

原文地址:https://www.cnblogs.com/xccnblogs/p/4883664.html