解决Debian 9 (stretch) 中apt-get update报错的问题


使用了很多方法,走了很多弯路,今天终于把课题组的网站服务器中更新源时遇到GPG error的问题解决了。服务器使用的是中科大的软件源(LUG@USTC),硬件配置为:

----------------------------------------------------------------------
CPU model            : Intel(R) Pentium(R) CPU G630 @ 2.70GHz
Number of cores      : 2
CPU frequency        : 1599.993 MHz
Total size of Disk   : 456.4 GB (7.7 GB Used)
Total amount of Mem  : 3850 MB (549 MB Used)
Total amount of Swap : 3991 MB (0 MB Used)
System uptime        : 8 days 23 hour 23 min
Load average         : 0.00, 0.00, 0.00
OS                   : Debian GNU/Linux 9
Arch                 : x86_64 (64 Bit)
Kernel               : 4.9.0-6-amd64
Virt                 : No Virt
Power time of disk   : 12817 Hours
----------------------------------------------------------------------

apt-get update时的报错信息为:

W: GPG error: https://mirrors.ustc.edu.cn/debian stretch-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010
W: The repository 'https://mirrors.ustc.edu.cn/debian stretch-updates InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: https://mirrors.ustc.edu.cn/debian stretch-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010
W: The repository 'https://mirrors.ustc.edu.cn/debian stretch-backports InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: https://mirrors.ustc.edu.cn/debian-security stretch/updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9D6D8F6BC857C906 NO_PUBKEY 8B48AD6246925553
W: The repository 'https://mirrors.ustc.edu.cn/debian-security stretch/updates InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: https://mirrors.ustc.edu.cn/debian stretch Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010 NO_PUBKEY EF0F382A1A7B6500
W: The repository 'https://mirrors.ustc.edu.cn/debian stretch Release' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.

这个问题出现了有一段时间了,之前浏览各大论坛,给出的解决方案最多的是将缺少的key通过key server安装到本地,使用的代码比如:

gpg --keyserver  pgpkeys.mit.edu --recv-keys 8B48AD6246925553 7638D0442B90D010 9D6D8F6BC857C906 EF0F382A1A7B6500
gpg -a --export 8B48AD6246925553 7638D0442B90D010 9D6D8F6BC857C906 EF0F382A1A7B6500 | sudo apt-key add -

然后未能解决问题,返回的代码大概意思是导入key失败。不过今天,我通过重新卸载安装”debian-archive-keyring”软件包解决了问题,代码贴下,卸载:

root@debian:~# dpkg --force-depends -P debian-archive-keyring
dpkg: debian-archive-keyring: dependency problems, but removing anyway as you requested:
 apt depends on debian-archive-keyring.

(Reading database ... 345652 files and directories currently installed.)
Removing debian-archive-keyring (2017.5) ...
Purging configuration files for debian-archive-keyring (2017.5) ...

然后使用”apt –fix-broken install”解决系统软件包依赖,重装”debian-archive-keyring”:

root@debian:~# apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  debian-archive-keyring
The following NEW packages will be installed:
  debian-archive-keyring
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 56.4 kB of archives.
After this operation, 121 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
WARNING: The following packages cannot be authenticated!
  debian-archive-keyring
Install these packages without verification? [y/N] y
Get:1 http://mirrors.163.com/debian stretch/main amd64 debian-archive-keyring all 2017.5 [56.4 kB]
Fetched 56.4 kB in 0s (132 kB/s)                  
Selecting previously unselected package debian-archive-keyring.
(Reading database ... 345639 files and directories currently installed.)
Preparing to unpack .../debian-archive-keyring_2017.5_all.deb ...
Unpacking debian-archive-keyring (2017.5) ...
Setting up debian-archive-keyring (2017.5) ...

最后回到起点,重新更新系统源,成功(Reading package lists… Done)!

root@debian:~# apt-get update
Ign:1 https://mirrors.ustc.edu.cn/debian stretch InRelease
Get:2 https://mirrors.ustc.edu.cn/debian stretch-updates InRelease [91.0 kB]
Get:3 https://mirrors.ustc.edu.cn/debian stretch-backports InRelease [91.8 kB]
Get:4 https://mirrors.ustc.edu.cn/debian-security stretch/updates InRelease [63.0 kB]
Get:5 https://mirrors.ustc.edu.cn/debian stretch Release [118 kB]
Get:6 https://mirrors.ustc.edu.cn/debian stretch-updates/main Sources [5,384 B]
Get:7 https://mirrors.ustc.edu.cn/debian stretch-updates/main amd64 Packages [11.0 kB]
Get:8 https://mirrors.ustc.edu.cn/debian stretch-updates/main Translation-en [6,782 B]
Get:9 https://mirrors.ustc.edu.cn/debian stretch-backports/main Sources [256 kB]
Get:10 https://mirrors.ustc.edu.cn/debian stretch-backports/contrib Sources [4,100 B]
Get:11 https://mirrors.ustc.edu.cn/debian stretch-backports/non-free Sources [5,908 B]
Get:12 https://mirrors.ustc.edu.cn/debian stretch-backports/main amd64 Packages [304 kB]
Get:13 https://mirrors.ustc.edu.cn/debian stretch-backports/main Translation-en [209 kB]
Get:14 https://mirrors.ustc.edu.cn/debian stretch-backports/contrib amd64 Packages [7,100 B]
Get:15 https://mirrors.ustc.edu.cn/debian stretch-backports/contrib Translation-en [5,770 B]
Get:16 https://mirrors.ustc.edu.cn/debian stretch Release.gpg [2,434 B]
Get:17 https://mirrors.ustc.edu.cn/debian stretch-backports/non-free amd64 Packages [18.1 kB]
Get:18 https://mirrors.ustc.edu.cn/debian stretch-backports/non-free Translation-en [24.3 kB]
Get:19 https://mirrors.ustc.edu.cn/debian-security stretch/updates/contrib Sources [1,384 B]
Get:20 https://mirrors.ustc.edu.cn/debian-security stretch/updates/main Sources [131 kB]
Get:21 https://mirrors.ustc.edu.cn/debian-security stretch/updates/non-free Sources [772 B]
Get:22 https://mirrors.ustc.edu.cn/debian-security stretch/updates/main amd64 Packages [363 kB]
Get:23 https://mirrors.ustc.edu.cn/debian-security stretch/updates/main Translation-en [160 kB]
Get:24 https://mirrors.ustc.edu.cn/debian-security stretch/updates/contrib amd64 Packages [1,776 B]
Get:25 https://mirrors.ustc.edu.cn/debian-security stretch/updates/contrib Translation-en [1,759 B]          
Get:26 https://mirrors.ustc.edu.cn/debian-security stretch/updates/non-free amd64 Packages [1,268 B]         
Get:27 https://mirrors.ustc.edu.cn/debian-security stretch/updates/non-free Translation-en [481 B]           
Get:28 https://mirrors.ustc.edu.cn/debian stretch/contrib Sources [44.7 kB]                                  
Get:29 https://mirrors.ustc.edu.cn/debian stretch/non-free Sources [79.7 kB]                                 
Get:30 https://mirrors.ustc.edu.cn/debian stretch/main Sources [6,756 kB]                                    
Get:31 https://mirrors.ustc.edu.cn/debian stretch/main amd64 Packages [7,122 kB]                             
Get:32 https://mirrors.ustc.edu.cn/debian stretch/main Translation-en [5,394 kB]                             
Get:33 https://mirrors.ustc.edu.cn/debian stretch/main amd64 DEP-11 Metadata [3,066 kB]                      
Get:34 https://mirrors.ustc.edu.cn/debian stretch/main DEP-11 64x64 Icons [6,804 kB]                         
Get:35 https://mirrors.ustc.edu.cn/debian stretch/main DEP-11 128x128 Icons [15.8 MB]                        
Get:36 https://mirrors.ustc.edu.cn/debian stretch/contrib amd64 Packages [50.9 kB]                           
Get:37 https://mirrors.ustc.edu.cn/debian stretch/contrib Translation-en [45.9 kB]                           
Get:38 https://mirrors.ustc.edu.cn/debian stretch/contrib amd64 DEP-11 Metadata [7,308 B]                    
Get:39 https://mirrors.ustc.edu.cn/debian stretch/contrib DEP-11 64x64 Icons [100 kB]                        
Get:40 https://mirrors.ustc.edu.cn/debian stretch/contrib DEP-11 128x128 Icons [254 kB]                      
Get:41 https://mirrors.ustc.edu.cn/debian stretch/non-free amd64 Packages [78.0 kB]                          
Get:42 https://mirrors.ustc.edu.cn/debian stretch/non-free Translation-en [80.1 kB]                          
Get:43 https://mirrors.ustc.edu.cn/debian stretch/non-free amd64 DEP-11 Metadata [7,180 B]                   
Get:44 https://mirrors.ustc.edu.cn/debian stretch/non-free DEP-11 64x64 Icons [30.0 kB]                      
Get:45 https://mirrors.ustc.edu.cn/debian stretch/non-free DEP-11 128x128 Icons [85.2 kB]                    
Fetched 47.7 MB in 19s (2,390 kB/s)                                                                          
Reading package lists... Done

发表评论

电子邮件地址不会被公开。

一条评论 “解决Debian 9 (stretch) 中apt-get update报错的问题”