2023年4月19日 星期三

Linux 更新套件清單出現 "public key is not available" 錯誤的解決辦法

昨天整理辦公室櫃子找到以前二哥上大瀚機器人時使用的 Acer D255 小筆電 (CPU 是 Atom N450, 乃 amd64 單核), 因為內建的 Win7 已無法使用, 後來 (約 2017 年時) 硬碟被我格式化改安裝了 Linux Mint, 但隨即束之高閣. 它的電池已壞但插電還能開機使用. 

今天想說在上面安裝 Thonny, 還可以用來跑跑 Python 程式, 我的原則就是要物盡其用, 但是我用 apt update 指令更新套件清單時卻出現 "public key is not available: NO_PUBKEY DD3C368A8DE1B7A0" 錯誤 :  
 
tony1966@tony1966-AOD255 ~ $ sudo apt update 
[sudo] password for tony1966:
Ign:2 http://packages.linuxmint.com serena InRelease                                                                        
Hit:3 http://archive.ubuntu.com/ubuntu xenial InRelease                                                                     
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease                                                           
Hit:5 http://archive.canonical.com/ubuntu xenial InRelease                                                                  
Hit:6 http://archive.ubuntu.com/ubuntu xenial-updates InRelease                                                             
Hit:7 http://packages.linuxmint.com serena Release                     
Get:1 https://deb.opera.com/opera stable InRelease [2590 B]            
Err:1 https://deb.opera.com/opera stable InRelease                                 
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DD3C368A8DE1B7A0    
Hit:9 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Fetched 2590 B in 7s (367 B/s)
Reading package lists... Done
Building dependency tree      
Reading state information... Done
782 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: https://deb.opera.com/opera stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DD3C368A8DE1B7A0
W: Failed to fetch http://deb.opera.com/opera/dists/stable/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DD3C368A8DE1B7A0
W: Some index files failed to download. They have been ignored, or old ones used instead.
 
爬文在下面這篇找到解決辦法 :


原來只要用 sudo apt-key adv 指令在後面附上 public key 即可. 不過它提供的第一個 key 伺服器 keys.gnupg.net 已掛點無法下載 :

tony1966@tony1966-AOD255 ~ $ sudo apt-key adv --keyserver keys.gnupg.net --recv-keys DD3C368A8DE1B7A0    
Executing: /tmp/tmp.T3Sc4HuoUR/gpg.1.sh --keyserver
keys.gnupg.net
--recv-keys
DD3C368A8DE1B7A0
gpg: requesting key 8DE1B7A0 from hkp server keys.gnupg.net
?: keys.gnupg.net: Host not found
gpgkeys: HTTP fetch error 7: couldn't connect: Success
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
gpg: keyserver communications error: keyserver unreachable
gpg: keyserver communications error: public key not found
gpg: keyserver receive failed: public key not found

改用另一個 key 伺服器 keyserver.ubuntu.com 就可以順利安裝 key 了 :

tony1966@tony1966-AOD255 ~ $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DD3C368A8DE1B7A0   
Executing: /tmp/tmp.MxsGmug9Bz/gpg.1.sh --keyserver
keyserver.ubuntu.com
--recv-keys
DD3C368A8DE1B7A0
gpg: requesting key 8DE1B7A0 from hkp server keyserver.ubuntu.com
gpg: key 8DE1B7A0: public key "Opera Software Archive Automatic Signing Key 2021 <packager@opera.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

解決 public key 問題再次執行 sudo apt update 就能順利更新清單了 : 

tony1966@tony1966-AOD255 ~ $ sudo apt update    
[sudo] password for tony1966:
Ign:2 http://packages.linuxmint.com serena InRelease                                                                        
Hit:3 http://archive.canonical.com/ubuntu xenial InRelease                                                                  
Hit:4 http://packages.linuxmint.com serena Release                                                                          
Get:1 https://deb.opera.com/opera stable InRelease [2590 B]                                   
Get:6 https://deb.opera.com/opera stable/non-free amd64 Packages [1184 B]     
Get:7 http://security.ubuntu.com/ubuntu xenial-security InRelease [99.8 kB]                                                 
Hit:8 http://archive.ubuntu.com/ubuntu xenial InRelease  
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [99.8 kB]          
Get:10 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [97.4 kB]                   
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [2049 kB]
Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [1525 kB]                                         
Fetched 3875 kB in 35s (111 kB/s)                                                                                           
Reading package lists... Done
Building dependency tree      
Reading state information... Done
782 packages can be upgraded. Run 'apt list --upgradable' to see them.

最後用 sudo apt upgrade 更新套件 :

tony1966@tony1966-AOD255 ~ $ sudo apt upgrade   

因為太久沒更新了, 累積達 700 多項, 這花了三個多小時, 在約 72% 時停住出現一個選項 : 




我查到下面這篇, 它建議按 Y 安裝套件維護者的更新版本 :


選好後大約過 10 幾分鐘就完成更新了. 

沒有留言 :