Debian12(bookworm)源配置文件修复缺少公钥问题

系统更新提示

Shell Session
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.sury.org/php  bookworm InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B188E2B695BD4743
W: Failed to fetch https://packages.sury.org/php/dists/bookworm/InRelease   The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B188E2B695BD4743
W: Some index files failed to download. They have been ignored, or old ones used instead.

解决办法

①使用 wget 下载并添加公钥

方法一

Shell Session
wget -qO - https://packages.sury.org/php/apt.gpg | tee -a /etc/apt/trusted.gpg.d/php.sury.org.gpg

方法二

Shell Session
wget -qO /etc/apt/trusted.gpg.d/sury-php.gpg https://packages.sury.org/php/apt.gpg

②从钥匙服务器获取公钥

Shell Session
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B188E2B695BD4743

③检查源配置文件

确保/etc/apt/sources.list.d/php.list 文件中的源配置正确无误。

Shell Session
deb [signed-by=/etc/apt/trusted.gpg.d/sury-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main