许久没有进行过更新的操作,今日在执行apt update的时候就出现 GPG 签名无效的问题。
前因
某日在对一台运行着 Debian 12 系统的 VPS 执行apt update的时候就出现 GPG 签名无效的相关问题,虽说是无伤大雅但是却着实是影响着对应软件的更新。当时出现的错误警告如下:
root@Debian-12-VM:~# apt update Get:1 http://security.debian.org/debian-security bookworm-security InRelease [48.0 kB] Hit:2 http://deb.debian.org/debian bookworm InRelease Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB] Get:4 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB] Get:5 http://repo.mysql.com/apt/debian bookworm InRelease [22.7 kB] Get:6 https://packages.sury.org/php bookworm InRelease [7,551 B] Get:7 http://security.debian.org/debian-security bookworm-security/main Sources [180 kB] Get:8 http://security.debian.org/debian-security bookworm-security/main amd64 Packages [284 kB] Get:9 http://security.debian.org/debian-security bookworm-security/main Translation-en [172 kB] Get:10 http://deb.debian.org/debian-security bookworm-security/non-free-firmware Sources [796 B] Get:11 http://deb.debian.org/debian-security bookworm-security/non-free-firmware amd64 Packages [688 B] Get:12 https://nginx.org/packages/mainline/debian bookworm InRelease [3,296 B] Err:5 http://repo.mysql.com/apt/debian bookworm InRelease The following signatures were invalid: EXPKEYSIG B7B3B788A8D3785C MySQL Release Engineering <mysql-build@oss.oracle.com> Hit:13 https://apt.myvestacp.com/bookworm bookworm InRelease Get:14 https://nginx.org/packages/mainline/debian bookworm/nginx amd64 Packages [44.0 kB] Get:15 https://packages.sury.org/php bookworm/main amd64 Packages [266 kB] Fetched 1,132 kB in 1s (768 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done 52 packages can be upgraded. Run 'apt list --upgradable' to see them. W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mysql.com/apt/debian bookworm InRelease: The following signatures were invalid: EXPKEYSIG B7B3B788A8D3785C MySQL Release Engineering <mysql-build@oss.oracle.com> W: Failed to fetch http://repo.mysql.com/apt/debian/dists/bookworm/InRelease The following signatures were invalid: EXPKEYSIG B7B3B788A8D3785C MySQL Release Engineering <mysql-build@oss.oracle.com> W: Some index files failed to download. They have been ignored, or old ones used instead.
重试一遍问题依旧,虽说不影响其他软件/组件的正常更新,但这样除了影响强迫症导致的“美观”之外,还有就是将无法对 Mysql 进行更新操作。大伙都说生产环境不建议盲目升级软件,但是我自个使用的升级影响不大,因此我大概率就是秉承着能升尽升的态度了吧。
后果
都明确的告诉我是那个签名有问题,还以为是一件“易过借火”的事情的,没想到处理起来还蛮多曲折的。
成功的执行结果
这一波算是有些投机取巧的了,因为走的就是安装时的路子来解决的。
操作有风险,操作前注意备份数据!备份数据!!备份数据!!!
- 下载当前新的deb文件
wget https://dev.mysql.com/get/mysql-apt-config_0.8.36-1_all.deb
输出如下:
--2025-11-11 22:37:03-- https://dev.mysql.com/get/mysql-apt-config_0.8.36-1_all.deb Resolving dev.mysql.com (dev.mysql.com)... 23.66.133.188, 2600:1406:5e00:7a3::2e31, 2600:1406:5e00:798::2e31 Connecting to dev.mysql.com (dev.mysql.com)|23.66.133.188|:443... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://repo.mysql.com//mysql-apt-config_0.8.36-1_all.deb [following] --2025-11-11 22:37:03-- https://repo.mysql.com//mysql-apt-config_0.8.36-1_all.deb Resolving repo.mysql.com (repo.mysql.com)... 23.42.93.51, 2600:1406:5e00:397::1d68, 2600:1406:5e00:388::1d68 Connecting to repo.mysql.com (repo.mysql.com)|23.42.93.51|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 18128 (18K) [application/x-debian-package] Saving to: ‘mysql-apt-config_0.8.36-1_all.deb’ mysql-apt-config_0.8.36-1_all.deb 100%[============================================================>] 17.70K --.-KB/s in 0s 2025-11-11 22:37:03 (277 MB/s) - ‘mysql-apt-config_0.8.36-1_all.deb’ saved [18128/18128]
- 安装
dpkg -i mysql-apt-config_0.8.36-1_all.deb
在里面选择对应的版本即可,其实大部分默认的就是需要的 8.4-lts 了。
- 执行
apt update命令
输出:Hit:1 http://security.debian.org/debian-security bookworm-security InRelease Hit:2 http://deb.debian.org/debian bookworm InRelease Hit:3 http://deb.debian.org/debian bookworm-updates InRelease Get:4 http://repo.mysql.com/apt/debian bookworm InRelease [22.7 kB] Hit:5 https://packages.sury.org/php bookworm InRelease Hit:6 http://deb.debian.org/debian-security bookworm-security InRelease Get:7 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts Sources [967 B] Get:8 http://repo.mysql.com/apt/debian bookworm/mysql-apt-config amd64 Packages [568 B] Get:9 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 Packages [14.5 kB] Hit:10 https://nginx.org/packages/mainline/debian bookworm InRelease Get:11 http://repo.mysql.com/apt/debian bookworm/mysql-tools amd64 Packages [4,165 B] Hit:12 https://apt.myvestacp.com/bookworm bookworm InRelease Fetched 43.0 kB in 1s (54.3 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done 8 packages can be upgraded. Run 'apt list --upgradable' to see them.
- 执行
apt list --upgradable命令
输出:Listing... Done mysql-client/unknown 8.4.7-1debian12 amd64 [upgradable from: 8.4.6-1debian12] mysql-common/unknown 8.4.7-1debian12 amd64 [upgradable from: 8.4.6-1debian12] mysql-community-client-core/unknown 8.4.7-1debian12 amd64 [upgradable from: 8.4.6-1debian12] mysql-community-client-plugins/unknown 8.4.7-1debian12 amd64 [upgradable from: 8.4.6-1debian12] mysql-community-client/unknown 8.4.7-1debian12 amd64 [upgradable from: 8.4.6-1debian12] mysql-community-server-core/unknown 8.4.7-1debian12 amd64 [upgradable from: 8.4.6-1debian12] mysql-community-server/unknown 8.4.7-1debian12 amd64 [upgradable from: 8.4.6-1debian12] mysql-server/unknown 8.4.7-1debian12 amd64 [upgradable from: 8.4.6-1debian12]
- 执行
apt upgrade命令
输出:Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done The following packages will be upgraded: mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-client-plugins mysql-community-server mysql-community-server-core mysql-server 8 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 40.0 MB of archives. After this operation, 16.4 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 mysql-server amd64 8.4.7-1debian12 [58.8 kB] Get:2 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 mysql-community-client amd64 8.4.7-1debian12 [3,270 kB] Get:3 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 mysql-community-client-core amd64 8.4.7-1debian12 [1,640 kB] Get:4 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 mysql-community-client-plugins amd64 8.4.7-1debian12 [1,626 kB] Get:5 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 mysql-community-server-core amd64 8.4.7-1debian12 [33.2 MB] Get:6 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 mysql-community-server amd64 8.4.7-1debian12 [67.5 kB] Get:7 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 mysql-client amd64 8.4.7-1debian12 [58.8 kB] Get:8 http://repo.mysql.com/apt/debian bookworm/mysql-8.4-lts amd64 mysql-common amd64 8.4.7-1debian12 [60.1 kB] Fetched 40.0 MB in 0s (80.6 MB/s) Reading changelogs... Done Preconfiguring packages ... (Reading database ... 73270 files and directories currently installed.) Preparing to unpack .../0-mysql-server_8.4.7-1debian12_amd64.deb ... Unpacking mysql-server (8.4.7-1debian12) over (8.4.6-1debian12) ... Preparing to unpack .../1-mysql-community-client_8.4.7-1debian12_amd64.deb ... Unpacking mysql-community-client (8.4.7-1debian12) over (8.4.6-1debian12) ... Preparing to unpack .../2-mysql-community-client-core_8.4.7-1debian12_amd64.deb ... Unpacking mysql-community-client-core (8.4.7-1debian12) over (8.4.6-1debian12) ... Preparing to unpack .../3-mysql-community-client-plugins_8.4.7-1debian12_amd64.deb ... Unpacking mysql-community-client-plugins (8.4.7-1debian12) over (8.4.6-1debian12) ... Preparing to unpack .../4-mysql-community-server-core_8.4.7-1debian12_amd64.deb ... Unpacking mysql-community-server-core (8.4.7-1debian12) over (8.4.6-1debian12) ... Preparing to unpack .../5-mysql-community-server_8.4.7-1debian12_amd64.deb ... Unpacking mysql-community-server (8.4.7-1debian12) over (8.4.6-1debian12) ... Preparing to unpack .../6-mysql-client_8.4.7-1debian12_amd64.deb ... Unpacking mysql-client (8.4.7-1debian12) over (8.4.6-1debian12) ... Preparing to unpack .../7-mysql-common_8.4.7-1debian12_amd64.deb ... Unpacking mysql-common (8.4.7-1debian12) over (8.4.6-1debian12) ... Setting up mysql-common (8.4.7-1debian12) ... Setting up mysql-community-server-core (8.4.7-1debian12) ... Setting up mysql-community-client-plugins (8.4.7-1debian12) ... Setting up mysql-community-client-core (8.4.7-1debian12) ... Setting up mysql-community-client (8.4.7-1debian12) ... Setting up mysql-client (8.4.7-1debian12) ... Setting up mysql-community-server (8.4.7-1debian12) ... Setting up mysql-server (8.4.7-1debian12) ... Processing triggers for man-db (2.11.2-2) ... Processing triggers for libc-bin (2.36-9+deb12u13) ... root@FloralwhiteBulky-VM:~# apt-cache search mysql-community-server mysql-community-server - MySQL Server mysql-community-server-core - MySQL Server Core Binaries mysql-community-server-core-dbgsym - debug symbols for mysql-community-server-core mysql-community-server-debug - Debug binaries for MySQL Server mysql-community-server-debug-dbgsym - debug symbols for mysql-community-server-debug
- 至此已算是升级成功。
失败的示范
虽说这几步操作没能成功,但也不妨记录在案以供参考。
按常理先执行以下命令:
root@Debian-12-VM:~# gpg --export --armor B7B3B788A8D3785C |apt-key add - gpg: directory '/root/.gnupg' created gpg: keybox '/root/.gnupg/pubring.kbx' created gpg: WARNING: nothing exported Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). gpg: no valid OpenPGP data found. root@Debian-12-VM:~# gpg --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C gpg: /root/.gnupg/trustdb.gpg: trustdb created gpg: key B7B3B788A8D3785C: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported gpg: Total number processed: 1 gpg: imported: 1 root@Debian-12-VM:~# gpg --export --armor B7B3B788A8D3785C |apt-key add - Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). OK root@Debian-12-VM:~# apt-key export A8D3785C | gpg --dearmour -o /etc/apt/trusted.gpg.d/pgdg.gpg Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
执行上面的命令之后,再次执行apt update时依旧报错。
再重新执行以下命令:
root@Debian-12-VM:~# apt-key list
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
......
......
/etc/apt/trusted.gpg.d/pgdg.gpg
-------------------------------
pub rsa4096 2023-10-23 [SC] [expires: 2027-10-23]
BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785C
uid [ unknown] MySQL Release Engineering <mysql-build@oss.oracle.com>
sub rsa4096 2023-10-23 [E] [expires: 2027-10-23]
......
......
root@Debian-12-VM:~# apt-key del A8D3785C
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
这时再次执行apt update时依旧报错。下面的操作都有所重复,干脆就忽略不记录了。
ChiuYut
2025年11月11日