RPM验证与数字签名(Verify/Signature)

摘要:
AcronymsExplainedTheRPMdocumentationusesGPGandPGPprettymuchinterchangeably,somuchso,infact,thatyoumaythinkthesearetypographicalerrors.Notso.PGPstandsforPrettyGoodPrivacy.InventedbyPhilZimmerman,PGPwasoriginallyinventedtoencrypte-mailtoallowforprivatecommunication.Basedonapublic-keycryptographyalgorithm,PGPalsosupportsencrypteddigitalsignatures.Thesesignaturesallowyoutoverifythatapackageyouhavedownloadedreallycomesfromthevendoryouthinkitdoes.Youdothisbyusingthevendor’spublickey.GPGstandsforGNUPrivacyGuard,afree,open-sourceimplementationofPGPfromtheGNUproject.GPGaimstobecompatiblewiththeOpenPGPInternetstandardasdefinedinRFC2440.Itstartedwhenanumberofdeveloperswantedafreeimplementation.Onesuchfreeimplementation,GPG,allowsLinuxvendorssuchasRedHattoincludePGPintheirproducts.So,inasense,GPGprovidesPGP.PGPhasalongandsomewhattroubledhistoryasanopen-sourceproductandasacommercialproduct.Seewww.philzimmermann.comforbackgroundonPGPanditslonghistory.Seewww.gnupg.orgformoredetailsonGPG.手动生成数字签名可查看官网:https://www.gentoo.org/doc/zh_cn/gnupg-user.xml两个注意事项创建数字认证之前要确保gpg-agent在运行,因为需要它穿件一个socket或者pipe用于连接$gpg-agent--daemon--use-standard-socket创建数字认证的时候不要用su之后的用户如果用的话gpg-agent将会失败gpg-agentfailstolaunch/usr/bin/pinentry.一旦有了数字认证key,就可以在制作RPM的时候设置相关数字签名宏。添加下面的代码到$HOME/.rpmmacros%_signaturegpg%_gpg_path/home/xxx/.gnupg%_gpg_namexxx%_gpgbin/usr/bin/gpg这样就可以在制作RPM包的时候加上--sign参数来加上数字签名。$rpm--addsignpackage.rpm也可以对现有的RPM修改数字签名。$rpm--resignpackage.rpm验证一个RPM包的数字签名$rpm-K-vpackage.rpm$rpm-K-vvpackage.rpm
RPM验证与数字签名(Verify/Signature)

摘自:https://blog.csdn.net/rhel_admin/article/details/32382391

2014年06月19日 23:17:42
阅读数:2798

RPM验证:

使用RPM数据库(/var/lib/rpm)的内容来比对目前Linux系统RPM软件文件,查看是否有改动


简单的用法:

  1. $rpm -Va #验证系统所有RPM包
  2. $rpm -V 已安装的RPM包 #验证指定的RPM包
  3. $rpm -Vf 某个RPM包文件 #验证这个文件
  4. $rpm -Vf /etc/yum.conf
  5. S.5....T. c /etc/yum.conf
  6. $
现在来简单的解释一下验证后的输出,输出一般来说有两部分;

表示文件的9个属性信息

  • S file Size differs 文件大小是否被改动
  • M Mode differs(includes permissions and file type) 文件的属性和类型是否被改动
  • 5 MD5 sum differs MD5内容是否被改动
  • D Device major/minor number mismatch 设备的主/次代码是否被改动
  • L readLink(2) path mismatch Link路径是否被改动
  • U User ownership differs 文件的所有人是否被改动
  • G Group ownership differs 文件的组是否被改动
  • T mTime differs 文件的修改是否是否被改动
  • P caPabilities differ
表示文件格式的信息
  • c %config configuration file 配置文件
  • d %doc documentation file 文档文件
  • g %ghost file 通常是该文件不会被某个燃机所包含 较少发生
  • l %license license file 许可证文件
  • r %readme readme file 自述文件

RPM数字签名:

这里主要从制作RPM的时候加入数字签名,这里用的是GPG。

这里简单说明一下GPG与PGP不同之处。来自与Fedora_RPM_documentation

GPG and PGP? Acronyms Explained
The RPM documentation uses GPG and PGP pretty much interchangeably, so much so, in fact, thatyou may think these are typographical errors. Not so.
PGP stands for Pretty Good Privacy. Invented by Phil Zimmerman, PGP was originally invented toencrypt e-mail to allow for private communication. Based on a public-key cryptography algorithm, PGPalso supports encrypted digital signatures. These signatures allow you to verify that a package youhave downloaded really comes from the vendor you think it does. You do this by using the vendor’spublic key.
GPG stands for GNU Privacy Guard, a free, open-source implementation of PGP from the GNUproject. GPG aims to be compatible with the OpenPGP Internet standard as defined in RFC 2440. Itstarted when a number of developers wanted a free implementation. One such free implementation,GPG, allows Linux vendors such as Red Hat to include PGP in their products. So, in a sense, GPGprovides PGP.
PGP has a long and somewhat troubled history as an open-source product and as a commercialproduct. See www.philzimmermann.com for background on PGP and its long history. Seewww.gnupg.org for more details on GPG.

手动生成数字签名可查看官网:https://www.gentoo.org/doc/zh_cn/gnupg-user.xml 两个注意事项

  1. 创建数字认证之前要确保gpg-agent在运行,因为需要它穿件一个socket或者pipe用于连接 $gpg-agent --daemon --use-standard-socket
  2. 创建数字认证的时候不要用su之后的用户 如果用的话gpg-agent将会失败gpg-agent fails to launch/usr/bin/pinentry (which in turn decides whether to launchpinentry-curses, or a QT or GTK equivalent).
一旦有了数字认证key,就可以在制作RPM的时候设置相关数字签名宏。添加下面的代码到$HOME/.rpmmacros
  1. %_signature gpg
  2. %_gpg_path /home/xxx/.gnupg
  3. %_gpg_name xxx <email address>
  4. %_gpgbin /usr/bin/gpg


这样就可以在制作RPM包的时候加上--sign参数来加上数字签名。
$rpmbuild -ba --sign xxx.spec


也可以对现有的RPM包增加数字签名。
$rpm --addsign package.rpm


也可以对现有的RPM修改数字签名。
$rpm --resign package.rpm 


验证一个RPM包的数字签名
  1. $rpm -K -v package.rpm
  2. $rpm -K -vv package.rpm

免责声明:文章转载自《RPM验证与数字签名(Verify/Signature)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇解读eXtremeComponents代码结构--转载仓颉输入法学习下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

fedora19安装后,需要安装的一些必备的软件包

安装rpmfusion源 Fedora 19的源:sudo yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-19.noarch.rpm  http://download1.rpmfusion.org/nonfree/...

配置CentOS6.5的yum源

      系统yum源(源,英文repository,就是资源库的意思;yum,全称Yellow dog Updater, Modified,是centos的软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包。)的位置在/etc/yum.repos.d/,系统默认的是CentO...

Centos7安装bcm43142无线网卡驱动 采用rpmbuild方法

一 安装依赖和环境   1 安装依赖(第二个如果找不到包可以不装) # yum group install 'Development Tools' # yum install redhat-lsb kernel-abi-whitelists # yum install kernel-devel-$(uname -r)   2 建立rpmbuild环境(注意...

Debian软件包管理系统

Debian包管理系统 Debian包管理系统也许是类Unix系统上最为复杂的包管理系统。Debian的机制是网络透明的(也就是他可以通过网络透明的安装远程器上的软件包),而Debian也是第一个进行使用这样打包系统的发行版本。RH的up2date是最近的与Debian相似的软件功能,而Slackware Linux并没有达到真正的网络透明的程度。熟...

yum 程序包管理简介

rpm可以实现程序的快速,简单安装(跟编译安装比),但是rpm自己不能解决依赖,所以很多工具为了自动解决依赖应运而生,其中yum就是其中之一。 yum解决依赖的办法: 必须有个文件服务器,里面放置所以的rpm包,以及包的相关元数据(-qi,-qR得到的数据)。元数据可以使用createrepo来创建。并放置在repodata目录下。 这个文件服务器可以...

【腾讯Bugly干货分享】Android 新一代多渠道打包神器

关于作者: 李涛,腾讯Android工程师,14年加入腾讯SNG增值产品部,期间主要负责手Q动漫、企鹅电竞等项目的功能开发和技术优化。业务时间喜欢折腾新技术,写一些技术文章,个人技术博客:www.ltlovezh.com 。 ApkChannelPackage是一种快速多渠道打包工具,同时支持基于V1和V2签名进行渠道打包。插件本身会自动检测Apk使用的签...