apt はキーが利用できないと仮定します。これは正しくありません。

apt はキーが利用できないと仮定します。これは正しくありません。

apt で解決できない奇妙な問題があったため、/var/lib/apt と /var/cache/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 の更新は同じエラーで失敗します。

答え1

一般的に、システム ディレクトリを単に削除するのは得策ではありません。パッケージをクリーンアップする必要がある場合は、パッケージを消去してから再インストールする方がよいでしょう。システムを手動でしか修復できない状態にしてしまった可能性もありますが、最も簡単な解決策を提供しようと思います。

Debian の適切なキーを取得するには、debian-archive-keyringパッケージを消去してから再インストールする必要があります。このパッケージは、すべての Debian アーカイブ キーを適切な場所に提供し、apt使用するために正しくインストールします。これらのキーは に存在し/etc/apt、適切に機能するために必要です。

関連情報