標(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即可解決問題。