大网数据广告活动
服务器运维问答

How to remove a yum repo GPG key?

· 52CE 我爱测

I have a custom RPM repo in Artifactory, and GPG signing keys were recently enabled. When I ran sudo yum check-updates I was prompted to add the key: Retrieving key from https://artifactory.example.com/myrepo/repodata/repomd.xml.…

问题原文

原帖链接 · cherdt · CC BY-SA 3.0

I have a custom RPM repo in Artifactory, and GPG signing keys were recently enabled.

When I ran sudo yum check-updates I was prompted to add the key:

Retrieving key from https://artifactory.example.com/myrepo/repodata/repomd.xml.key
Importing GPG key 0x12345678:
 Userid     : "John Doe <[email omitted]>"
 Fingerprint: 1234 5678 90ab cdef 1234 5678 90ab cdef 1234 5678
 From       : https://artifactory.example.com/myrepo/repodata/repomd.xml.key

I added the key, which was successful. However, I would now like to remove the key. I need to add the key programmatically (e.g. via Ansible) to numerous servers, and so I would like to reproduce the same behavior as before (where I am prompted to add the key) so that I can confirm that adding the key programmatically changes this behavior.

I have tried using yum-config-manager to unset the gpgkey, but the behavior remains the same (yum does not prompt me to accept the key):

sudo yum-config-manager --setopt=artifactory.gpgkey='' --save

I've additionally deleted the yum cache (sudo yum clean all and sudo rm -rf /var/cache/yum).

How can I remove this key from the yum repo configuration?

Version info:

$ yum --version
3.4.3

已采纳解答

原帖链接 · cherdt · CC BY-SA 3.0

Yum has a GPG keyring for repos that support GPG metadata signing. On my system, the relevant paths for this particular repo were:

  • /var/lib/yum/repos/x86_64/7/artifactory/gpgdir
  • /var/lib/yum/repos/x86_64/7/artifactory/gpgdir-ro

I was able to delete the GPG keys from those keyrings:

sudo gpg --homedir /var/lib/yum/repos/x86_64/7/artifactory/gpgdir --delete-key 12345678
sudo gpg --homedir /var/lib/yum/repos/x86_64/7/artifactory/gpgdir-ro --delete-key 12345678

Running sudo yum check-update at this point still did not prompt me to accept the key. I ran sudo yum clean metadata, and after that sudo yum check-update did re-prompt me to accept the GPG key.

I found PackageCloud's page on YUM GPG keys helpful in arriving at this solution.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-03-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。