解決樹莓派軟件源更新時(shí)公鑰問題

標(biāo)簽: 樹莓派 軟件源 公鑰


【參考鏈接】
如何更新Debian源和導(dǎo)入公鑰
Ubuntu的軟件源更新常見問題及解決

【問題說明】

在另一篇文章(樹莓派安裝KodExplorer變身私人云桌面)中,為了安裝PHP7.0(通過軟件倉(cāng)庫(kù)安裝而不是編譯安裝),需要編輯文件sudo vim /etc/apt/sources.list,添加軟件源:

deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi

結(jié)果添加了軟件源之后進(jìn)行sudo apt-get update的時(shí)候報(bào)錯(cuò),錯(cuò)誤信息大致如下:

W: GPG error: http://mirrordirector.raspbian.org/raspbian stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9165938D90FDDD2E
W: The repository 'http://mirrordirector.raspbian.org/raspbian stretch 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: There is no public key available for the following key IDs:
9165938D90FDDD2E
E: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/stretch/main/binary-armhf/Packages.xz Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.

錯(cuò)誤信息大致意思為沒有找到對(duì)應(yīng)的公鑰,所以軟件源地址不被信任。

【解決方案】

解決方案就是導(dǎo)入對(duì)應(yīng)倉(cāng)庫(kù)的公鑰,命令格式為:

gpg --keyserver <KeyServer> --recv <公鑰簽名> gpg --export --armor <公鑰簽名> | sudo apt-key add 

也可以用如下格式:

apt-key adv --keyserver <KeyServer> --recv-keys <公鑰簽名>
gpg --export --armor 40976EAF437D05B5 | sudo apt-key add -

其中:
<KeyServer>,key服務(wù)器,可以填 keyserver.ubuntu.com ,當(dāng)然也可以填其他的。
在本例中,按照上面的格式,執(zhí)行:

gpg --keyserver  keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E
gpg --export --armor  9165938D90FDDD2E | sudo apt-key add -

然后再執(zhí)行sudo apt-get update即可解決問題。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容