mat*_*igo 177 apt keyrings 21.10
最近我在运行时注意到一些问题,apt系统会警告我密钥环已弃用:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
8 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: https://packages.microsoft.com/repos/edge/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: https://download.sublimetext.com/apt/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
Run Code Online (Sandbox Code Playgroud)
这并不会阻止我执行更新,但我宁愿在更新系统时看不到这一点。未来我们应该如何存储可信的 GPG 密钥?
mat*_*igo 253
解决此问题的一种方法是从已弃用的密钥环中导出 GPG 密钥并将其存储在/usr/share/keyrings. 幸运的是,这并不太难:
打开终端(如果尚未打开)
列出现有的键:
$ sudo apt-key list
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
/etc/apt/trusted.gpg
--------------------
pub rsa4096 2017-05-08 [SCEA]
1EDD E2CD FC02 5D17 F6DA 9EC0 ADAE 6AD2 8A8F 901A
uid [ unknown] Sublime HQ Pty Ltd <support@sublimetext.com>
sub rsa4096 2017-05-08 [S]
pub rsa2048 2015-10-28 [SC]
BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF
uid [ unknown] Microsoft (Release signing) <gpgsecurity@microsoft.com>
Run Code Online (Sandbox Code Playgroud)
从这里,我们可以导出密钥:
sudo apt-key export BE1229CF | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg
Run Code Online (Sandbox Code Playgroud)
注意:该BE1229CF值来自代码的最后 8 个字符pub。
可能会出现以下消息:
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Run Code Online (Sandbox Code Playgroud)
现在我们可以更新存储库的 apt 源文件(例如/etc/apt/sources.list.d/microsoft.list),添加一个signed-by标签:
deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/edge/ stable main
Run Code Online (Sandbox Code Playgroud)
更新apt以确认消息已消失:
sudo apt update
...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up-to-date.
W: https://download.sublimetext.com/apt/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
Run Code Online (Sandbox Code Playgroud)
删除原来的签名:
sudo apt-key del BE1229CF
Run Code Online (Sandbox Code Playgroud)
这可以通过每条警告消息来完成。一旦完成,apt就不会再抱怨。
小智 164
尝试这个
cd /etc/apt
sudo cp trusted.gpg trusted.gpg.d
Run Code Online (Sandbox Code Playgroud)
hey*_*ema 40
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.
Run Code Online (Sandbox Code Playgroud)
注意:这些警告消息可以由“其他软件”选项卡中任何启用的存储库或 ppa生成Software & Updates。
修复示例:
对于此警告消息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.
Run Code Online (Sandbox Code Playgroud)
我们查看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
Run Code Online (Sandbox Code Playgroud)
然后我们使用上面的最后 8 个数字字符将此条目转换为 .gpg 文件...
sudo apt-key export 91E7EE5E | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/team-xbmc.gpg
Run Code Online (Sandbox Code Playgroud)
对 生成的每条警告消息重复上述命令sudo apt update。
小智 7
考虑到提供的所有好的建议,我制作了一个助手 oneliner 来自动化所有键的过程:
sudo apt-key list 2>&1 | grep -E '(trusted.gpg.d)' -A 3 | grep -v '^\-\-' | grep -v '^pub ' | sed 's@.*/trusted.gpg.d/\(.*\)@\1@g' | awk 'NR%2{printf "%s ",$0;next;}1' | awk '{print "sudo apt-key export "$10$11" | sudo gpg --dearmour -o /usr/share/keyrings/"$1}' | xargs -I{} eval("{}")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
294143 次 |
| 最近记录: |