Apt

當我想更新時出現 GPG 錯誤

  • March 2, 2021

我剛剛安裝了 Kali NetHunter,我正在嘗試做一個簡單的操作apt update,但看起來缺少公鑰

root@kali:~# apt-get update
 0% [Waiting for headers] [Connected to packages.microsoft.com (13.8Get:2 https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease [3232 B]
 Hit:1 http://kali.download/kali kali-rolling InRelease
 Err:2 https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease
   The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
 Reading package lists... Done
 W: GPG error: https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
 E: The repository 'https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch 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.

我試過

curl -s https://packages.microsoft.com/repos/microsoft-debian-stretch-prod/dists/stretch/Release.gpg | apt-key add -

wget --no-check-certificate https://packages.microsoft.com/repos/microsoft-debian-stretch-prod/dists/stretch/Release.gpg | apt-key add -

結果是gpg: no valid OpenPGP data found雙方

我找到的解決方法是刪除/etc/apt/sources.list.d/microsoft.list並確保 kali repo 未註釋並且位於 main/etc/apt/sources.list

從微軟載入密鑰

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

引用自:https://unix.stackexchange.com/questions/522238