apt-get update
报错
root@2870e7cf8e74:/usr/tools# apt-get update
Ign:1 https://mirrors.aliyun.com/ubuntu trusty InRelease
Get:2 https://mirrors.aliyun.com/ubuntu trusty Release [58.5 kB]
Get:3 https://mirrors.aliyun.com/ubuntu trusty Release.gpg [933 B]
Ign:3 https://mirrors.aliyun.com/ubuntu trusty Release.gpg
Reading package lists... Done
W: GPG error: https://mirrors.aliyun.com/ubuntu trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
E: The repository 'https://mirrors.aliyun.com/ubuntu trusty Release' 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.
解决办法:
将不可用的pubkey加到ubuntu服务器,从上面可以看到如下pubkey
NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
使用以上pubkey拼接如下命令
gpg --keyserver keyserver.ubuntu.com --recv 40976EAF437D05B5
gpg --export --armor 40976EAF437D05B5 | apt-key add -
gpg --keyserver keyserver.ubuntu.com --recv 3B4FE6ACC0B21F32
gpg --export --armor 3B4FE6ACC0B21F32 | apt-key add -
我的环境因为是docker中的Python环境 ,默认用户是root,所以不用加sudo,如果非root用户可能会需要切换用户获取权限。则命令如下:
sudo gpg --keyserver keyserver.ubuntu.com --recv 40976EAF437D05B5
sudo gpg --export --armor 40976EAF437D05B5 | sudo apt-key add -
sudo gpg --keyserver keyserver.ubuntu.com --recv 3B4FE6ACC0B21F32
sudo gpg --export --armor 3B4FE6ACC0B21F32 | sudo apt-key add -
执行完以上命令后可以正常执行apt-update
命令
root@2870e7cf8e74:/usr/tools# apt-get update
Ign:1 https://mirrors.aliyun.com/ubuntu trusty InRelease
Get:2 https://mirrors.aliyun.com/ubuntu trusty Release [58.5 kB]
Get:3 https://mirrors.aliyun.com/ubuntu trusty Release.gpg [933 B]
Get:4 https://mirrors.aliyun.com/ubuntu trusty/main amd64 Packages [1350 kB]
Get:5 https://mirrors.aliyun.com/ubuntu trusty/multiverse amd64 Packages [132 kB]
Get:6 https://mirrors.aliyun.com/ubuntu trusty/restricted amd64 Packages [13.0 kB]
Get:7 https://mirrors.aliyun.com/ubuntu trusty/universe amd64 Packages [5859 kB]
Fetched 7414 kB in 22s (343 kB/s)
Reading package lists... Done