Ubuntu 24.04执行sudo apt update时出现Sublime Text源GPG公钥错误的解决方法咨询
嘿,我在Ubuntu 24.04上执行sudo apt update时碰到了Sublime Text软件源的GPG公钥验证错误,具体报错信息如下:
Err:5 https://download.sublimetext.com apt/stable/ InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F57D4F59BD3DF454
Reading package lists... Done
W: https://download.sublimetext.com/apt/stable/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/sublimehq-pub.gpg are ignored as the file has an unsupported filetype.
W: GPG error: https://download.sublimetext.com apt/stable/ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F57D4F59BD3DF454
E: The repository 'https://download.sublimetext.com apt/stable/ InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
查了相关方案后,整理出以下亲测有效的修复步骤:
先移除旧的、格式不被系统支持的密钥文件:
sudo rm /etc/apt/trusted.gpg.d/sublimehq-pub.gpg下载Sublime Text官方公钥,转换为Ubuntu 24.04支持的格式后,存储到系统推荐的密钥目录:
curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | sudo gpg --dearmor -o /usr/share/keyrings/sublimehq-archive-keyring.gpg修正Sublime Text的源配置,让APT明确使用刚才导入的密钥验证源合法性:
- 打开源配置文件:
sudo nano /etc/apt/sources.list.d/sublime-text.list - 将文件内容替换为:
deb [signed-by=/usr/share/keyrings/sublimehq-archive-keyring.gpg] https://download.sublimetext.com/ apt/stable/ - 按
Ctrl+O保存文件,再按Ctrl+X退出编辑器
- 打开源配置文件:
最后再次执行更新命令,验证问题是否解决:
sudo apt update
补充说明:Ubuntu 24.04对APT的密钥管理做了升级,不再允许将未处理的密钥直接放在/etc/apt/trusted.gpg.d/目录下,必须将密钥存储在/usr/share/keyrings/并在源配置中指定签名密钥路径,才能确保软件源的验证安全。
备注:内容来源于stack exchange,提问作者Alex

