我刪除了 /var/lib/apt 和 /var/cache/apt 因為我遇到了無法擺脫的 apt 奇怪問題。
現在我總是得到:
Get:1 http://security-cdn.debian.org buster/updates InRelease [65.4 kB]
Err:1 http://security-cdn.debian.org buster/updates InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA8E81B4331F7F50 NO_PUBKEY 112695A0E562B32A
Reading package lists... Done
W: GPG error: http://security-cdn.debian.org buster/updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA8E81B4331F7F50 NO_PUBKEY 112695A0E562B32A
E: The repository 'http://security.debian.org buster/updates 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.
這顯然是不正確的。但好吧,刪除 /etc/apt/trusted.gpg 並重新開始:
# rm /etc/apt/trusted.gpg
# apt-key adv --keyserver pgp.mit.edu --recv-keys AA8E81B4331F7F50
Executing: /tmp/apt-key-gpghome.DwxpIbllfu/gpg.1.sh --keyserver pgp.mit.edu --recv-keys AA8E81B4331F7F50
gpg: key EDA0D2388AE22BA9: public key "Debian Security Archive Automatic Signing Key (9/stretch) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
# apt-key adv --keyserver pgp.mit.edu --recv-keys 112695A0E562B32A
Executing: /tmp/apt-key-gpghome.TFiPCm4ThF/gpg.1.sh --keyserver pgp.mit.edu --recv-keys 112695A0E562B32A
gpg: key 4DFAB270CAA96DFA: public key "Debian Security Archive Automatic Signing Key (10/buster) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
# apt-key list
/etc/apt/trusted.gpg
--------------------
pub rsa4096 2017-05-22 [SC] [expires: 2025-05-20]
6ED6 F5CB 5FA6 FB2F 460A E88E EDA0 D238 8AE2 2BA9
uid [ unknown] Debian Security Archive Automatic Signing Key (9/stretch) <[email protected]>
sub rsa4096 2017-05-22 [S] [expires: 2025-05-20]
pub rsa4096 2019-04-14 [SC] [expires: 2027-04-12]
5E61 B217 265D A980 7A23 C5FF 4DFA B270 CAA9 6DFA
uid [ unknown] Debian Security Archive Automatic Signing Key (10/buster) <[email protected]>
sub rsa4096 2019-04-14 [S] [expires: 2027-04-12]
# apt update
Get:1 http://security-cdn.debian.org buster/updates InRelease [65.4 kB]
Err:1 http://security-cdn.debian.org buster/updates InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA8E81B4331F7F50 NO_PUBKEY 112695A0E562B32A
Reading package lists... Done
W: GPG error: http://security-cdn.debian.org buster/updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA8E81B4331F7F50 NO_PUBKEY 112695A0E562B32A
E: The repository 'http://security.debian.org buster/updates 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.
Apt 只是顯示遠離現實的訊息。這是在說謊!怎麼可能?
PS:我應該說,在刪除 /var/lib/apt 和 /var/apt/cache 之前,我已經建立了備份。當我將備份複製回來時,沒有任何變化。看來還有其他東西壞了。
PSS:我還刪除了 /etc/apt、/var/lib/apt、/var/cache/apt 並透過「dpkg -i apt_1.8.2_amd64.deb」重新安裝了 apt。所有目錄都從頭開始重新創建,但 apt update 仍然失敗並出現相同的錯誤!
答案1
一般來說,簡單地刪除系統目錄並不是一個好主意。如果您需要清理軟體包,最好將其清除然後重新安裝。您的系統可能處於現在只能手動修復的狀態,但我會盡力提供可能有效的最簡單的解決方案。
要獲得 Debian 的正確金鑰,您應該清除並重新安裝該debian-archive-keyring
軟體包。該軟體包在正確的位置提供了所有 Debian 存檔密鑰,並正確安裝它們以apt
供使用。這些密鑰存在/etc/apt
並且是正常運作所必需的。