使用apt-get时出现 “no public key available” 的解决方法

在 Debian 和 Ubuntu 下运行 apt-get update 刷新更新源的时候,经常遇到 “There is no public key available for the following key IDs” 的问题,具体表现为以下错误提示:

W:There is no public key available for the following key IDs: 3B4FE6ACC0B21F32,
W:There is no public key available for the following key IDs: 3B4FE6ACC0B21F32,

解决方法如下,

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32

把 3B4FE6ACC0B21F32 替换为你出现问题的IDs。另外,如果有如下问题,是因为加入了 natty-backports 源,删掉即可:

W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/natty-backports/main/source/Sources 404 Not Found [IP: 91.189.91.13 80],
W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/natty-backports/restricted/source/Sources 404 Not Found [IP: 91.189.91.13 80],
W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/natty-backports/universe/source/Sources 404 Not Found [IP: 91.189.91.13 80],
W:Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/natty-backports/multiverse/source/Sources 404 Not Found [IP: 91.189.91.13 80],

运行如下命令:

sudo sed -i '/natty\-backports/d' /etc/apt/sources.list{,.d/*}
发布于:2019-11-03 18:16:55