英文:
NO_PUBKEY for apt.releases.hashicorp.com in apt
问题
当运行 sudo apt update 时,我遇到以下错误:
Err:4 https://apt.releases.hashicorp.com focal InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA16FCBCA621E701
如何修复这个问题?
英文:
When running sudo apt update, I am presented with the following error:
Err:4 https://apt.releases.hashicorp.com focal InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA16FCBCA621E701
How can I fix this?
答案1
得分: 11
移除/etc/apt/sources.list.d/目录下现有的Hashicorp文件,然后按照官方指南执行以下步骤:
sudo -s
wget -O- https://apt.releases.hashicorp.com/gpg |
gpg --dearmor > /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" > /etc/apt/sources.list.d/hashicorp.list
apt update
英文:
Remove the exiting Hashicorp files under /etc/apt/sources.list.d/ and then follow the official guide:
sudo -s
wget -O- https://apt.releases.hashicorp.com/gpg |
gpg --dearmor > /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" > /etc/apt/sources.list.d/hashicorp.list
apt update
答案2
得分: 0
The GPG key is outdated or missing.
Run this code to remove the outdated key sudo rm /usr/share/keyrings/hashicorp-archive-keyring.gpg
And this to obtain the current key: curl https://apt.releases.hashicorp.com/gpg | gpg --dearmor > /usr/share/keyrings/hashicorp-archive-keyring.gpg
I had to run the last one under root (sudo -s), as I couldn't get sudo to work with the pipe character. Not really sure why.
英文:
The GPG key is outdated or missing.
Run this code to remove the outdated key sudo rm /usr/share/keyrings/hashicorp-archive-keyring.gpg
And this to obtain the current key: curl https://apt.releases.hashicorp.com/gpg | gpg --dearmor > /usr/share/keyrings/hashicorp-archive-keyring.gpg
I had the run that last one under root (sudo -s), as I couldn't get sudo to play ball with the pipe character. Not really sure why
答案3
得分: 0
问题出在正在使用的sources.list文件。最终它链接到一个密钥环,其中不包含密钥AA16FCBCA621E701。
在我的情况下,这个文件是/etc/apt/sources.list.d/hashicorp.list
deb [arch=amd64 signed-by=/usr/share/keyrings/terraform-archive-keyring.gpg] https://apt.releases.hashicorp.com jammy main
上述说明(感谢MacroMan),引导我到了这里(它创建了一个新的有效的hashicorp-archive-keyring.gpg,他的原始指令除非你以su - root身份运行,否则不起作用,而我从不这样做)
curl https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
使用新的密钥环,编辑上述文件,将terraform-archive-keyring.gpg替换为hashicorp-archive-keyring.gpg,然后运行sudo apt-get update时不应出现错误。
或者(我没有运行这个,但有人可能会发现它有用,因为它使用sudo tee重新创建了sources.list,所以不需要以root身份运行,就像>一样)
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee etc/apt/sources.list.d/hashicorp.list
英文:
So the problem is with the sources.list file being used. Ultimately it links to a keyring, which doesn't contain key AA16FCBCA621E701.
In my case this was the file /etc/apt/sources.list.d/hashicorp.list
deb [arch=amd64 signed-by=/usr/share/keyrings/terraform-archive-keyring.gpg] https://apt.releases.hashicorp.com jammy main
The above notes (thank you MacroMan), led me to this (which creates a new, valid hashicorp-archive-keyring.gpg, his original instructions don't work unless you're running as su - root, which I never do)
curl https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
With the new keyring, edit the above file to replace terraform-archive-keyring.gpg with hashicorp-archive-keyring.gpg and sudo apt-get update should run without errors.
Alternatively (I didn't run this, but someone might find it useful, as it recreates the sources.list using sudo tee, so doesnt need to be run as root, as > does)
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee etc/apt/sources.list.d/hashicorp.list
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论