![密钥存储在旧版 trust.gpg 密钥环 (/etc/apt/trusted.gpg) 中](https://linux22.com/image/1026514/%E5%AF%86%E9%92%A5%E5%AD%98%E5%82%A8%E5%9C%A8%E6%97%A7%E7%89%88%20trust.gpg%20%E5%AF%86%E9%92%A5%E7%8E%AF%20(%2Fetc%2Fapt%2Ftrusted.gpg)%20%E4%B8%AD.png)
我刚刚从 Ubuntu 21.10 升级到 22.04。
sudo apt update
以以下警告结束...
W: https://linux.teamviewer.com/deb/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://apt.keepsolid.com/ubuntu/dists/groovy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://linux.dropbox.com/ubuntu/dists/disco/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://download.virtualbox.org/virtualbox/debian/dists/hirsute/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://download.opensuse.org/repositories/home:/IBBoard:/cawbird/xUbuntu_22.04/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://ppa.launchpad.net/solaar-unifying/stable/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://ppa.launchpad.net/team-xbmc/ppa/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
Synaptic
重新加载时显示相同的警告。
审查man apt-key
并不能让我澄清这一点。
我思考这是因为 Ubuntu 22.04 已从使用 /etc/apt/trusted.gpg 转变为使用位于 /etc/apt/trusted.gpg.d 中的单独 .gpg 文件。
这些密钥可以相互转换吗,还是必须删除这些密钥并重新导入?
答案1
修复这些警告信息的简单方法sudo apt update
由...生成
W: https://linux.teamviewer.com/deb/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://apt.keepsolid.com/ubuntu/dists/groovy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://linux.dropbox.com/ubuntu/dists/disco/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://download.virtualbox.org/virtualbox/debian/dists/hirsute/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://download.opensuse.org/repositories/home:/IBBoard:/cawbird/xUbuntu_22.04/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://ppa.launchpad.net/solaar-unifying/stable/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://ppa.launchpad.net/team-xbmc/ppa/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
笔记:这些警告信息可由任何已启用Software & Updates
“其他软件”选项卡中的 repo 或 ppa 。
修复示例:
对于此警告信息sudo apt update
...
W: http://ppa.launchpad.net/team-xbmc/ppa/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
我们查看sudo apt-key list
并找到 xbmc 的这个条目...
pub rsa1024 2009-01-20 [SC]
1897 01DA 570C 56B9 488E F60A 6D97 5C47 91E7 EE5E
uid [ unknown] Launchpad PPA for XBMC for Linux
然后我们将这个条目转换为 .gpg 文件,使用上面的最后 8 位数字字符...
sudo apt-key export 91E7EE5E | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/team-xbmc.gpg
/etc/apt/trusted.gpg
您可以选择通过运行以下命令删除已弃用的密钥:
sudo apt-key --keyring /etc/apt/trusted.gpg del 91E7EE5E
对生成的每个警告消息重复上述命令sudo apt update
。
答案2
在迁移到 Ubuntu 22.04 后遇到了这个问题,我想添加我的解决方案。我有很多密钥需要更新/转换。这不是最佳解决方案,但效果很好。
此解决方案仅适用于 Ubuntu 22.04,版本号为bash
5.2.16。其他发行版和版本可能不起作用。
一行代码即可将所有弃用的键转换为新格式。
在运行之前,请花点时间了解你在这里做什么!!还要确保你的版本bash
不是太旧。我的bash
版本:GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
for KEY in $(apt-key --keyring /etc/apt/trusted.gpg list | grep -E "(([ ]{1,2}(([0-9A-F]{4}))){10})" | tr -d " " | grep -E "([0-9A-F]){8}\b" ); do K=${KEY:(-8)}; apt-key export $K | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/imported-from-trusted-gpg-$K.gpg; done
对于那些想要更易读的内容的人来说......
for KEY in $( \
apt-key --keyring /etc/apt/trusted.gpg list \
| grep -E "(([ ]{1,2}(([0-9A-F]{4}))){10})" \
| tr -d " " \
| grep -E "([0-9A-F]){8}\b" \
); do
K=${KEY:(-8)}
apt-key export $K \
| sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/imported-from-trusted-gpg-$K.gpg
done
解释:
检索已知密钥的列表:
apt-key list
查找所有前面有 1 或 2 个空格且长度为 4 个字符的十六进制字符组。获取每行有 10 个组的集合。这提供了完整的调号。
grep -E "(([ ]{1,2}(([0-9A-F]{4}))){10})"
修剪(删除)找到的每一行上的所有空格,以使调号不被空格打断:
tr -d " "
抓取每行的最后 8 个字符:
grep -E "([0-9A-F]){8}\b"
现在我们有了一组密钥后缀,每个后缀长度为 8 个字符。
循环遍历每个键后缀,将当前后缀放在
KEY
变量中:for KEY in $(…); do
将最后 8 个字符分配给变量
K
:K=${KEY:(-8)};
导出与签名匹配的密钥
K
并将其传递/管道传输到以下位置gpg
以正确存储:apt-key export $K | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/imported-from-trusted-gpg-$K.gpg
循环直到处理完所有键。
done
不再享受弃用警告。
答案3
对我有用的是:
mv /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/
答案4
我已经转身@heynnema 的回答放入一个函数中,您可以将其放在下面.bashrc
以方便使用。这需要两个参数:密钥(最后 8 个字符)和输出 GPG 文件的目标文件名。
function apt-key-migrate {
typeset key="$1"
typeset dest="$2"
if [ -z "$key" ] || [ -z "$dest" ];
then
echo "Usage: apt-key-migrate <key> <destination>"
return 1
fi
sudo apt-key export $key | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/$dest.gpg
}
例子:apt-key-migrate 91E7EE5E team-xbmc