07-gpg:keyserver receive failed:Server indicated a failure

现象

1
2
3
4
5
6
7
8
Get:5 http://xxxxxx
Err:5 http://xxxxxx
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY xxxxxxxx('公钥编码')

# 并且伴随出现
E: The repository 'http://xxxxxx‘ 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-get 源时,执行 apt-get update 命令时,原因是没有新源地址的公钥。解决的过程如下:

1
sudo gpg --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C

此时可能提示安装 gpg,

1
apt-get install gpg

如果使用代理上网,需要加上代理声明

1
2
3
4
5
6
7
8
# 执行如下命令
sudo gpg --keyserver --keyserver-options http-proxy=ip地址:端口 keyserver.ubuntu.com --recv-keys 871920D1991BC93C

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.Fh0fq4Rzek/gpg.1.sh --keyserver-options http-proxy=cmproxy.gmcc.net:8081 --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9
gpg: key 73A4F27B8DD47936: public key "Debian Archive Automatic Signing Key (11/bullseye) <ftpmaster@debian.org>" imported
gpg: Total number processed: 1
gpg: imported: 1

添加成功后终端输出为

1
2
3
gpg: key '公钥编码': public key "871920D1991BC93C" imported
gpg: Total number processed: 1
gpg: imported: 1

但是有的时候还是会报如下错误

1
gpg: keyserver receive failed: Server indicated a failure

这个时候需要你去keyserver的官网 https://keyserver.ubuntu.com/ ,把你的 公钥编码 输进去,然后点 search key, 然后把官网提供的 公钥文件 下载到本地。

然后执行 apt-key add <公钥文件> 添加公钥文件。然后再执行 apt-get 即可。


07-gpg:keyserver receive failed:Server indicated a failure
https://flepeng.github.io/002-Linux-13-包管理-02-apt-get-07-gpg:keyserver-receive-failed:Server-indicated-a-failure/
作者
Lepeng
发布于
2021年7月5日
许可协议