6

After sudo apt-get update I often see this error:

W: GPG error: http://archive.hivemind.me all Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3C962022012520A0

There are numerous reports and responses on AskUbuntu. They all require either (1) Lots of manual spelunking and multiple shell commands, or (2) Download of an external script, or (3) installation of a very-heavy GUI tool that is serious over-compensating for the problem.

Can someone who is not #!/bin/bash challenged provide a simple one-liner to resolve the problem?

1 Answer 1

9

I'm glad you asked, astute Ubuntu user. Why yes there is a solution that will make you very happy. And here it is:

sudo apt-get update 2>&1 |
sed -ne 's?^.*NO_PUBKEY ??p' |
xargs -r -- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys

Boom, that's it. No wasted time searching web sites, mucking with the shell, etc.

5
  • I'd recommend pulling in key's and using apt-key manually.
    – earthmeLon
    Dec 31, 2016 at 19:07
  • @earthmeLon I'm curious what you are suggesting with using apt-key manually? I certainly want to make this one-liner as robust and useful as possible. BTW, this can be found here with lots of other goodies: docs.google.com/spreadsheets/d/… Dec 31, 2016 at 19:13
  • 1
    I'm saying that blindly and automatically adding keys to apt-key during update could be seen as insecure. I think you'd just be best learning apt-key and using it manually, especially because instead of wget, you could just use --keyserver and have apt-key do the work. Also, not all keys will be stored on Ubuntu's keyserver. Glad to see you found a working solution to your problem, but wanted to give you some additional information.
    – earthmeLon
    Dec 31, 2016 at 19:18
  • 1
    Good points and I agree with them. However, if you are comfortable with the all the sources this can be a viable option. Thanks! Jan 1, 2017 at 20:32
  • 1
    @earthmeLon: I agree with you in general, however I see at least one reasonable use case for an automated approach: a lost or severely outdated Apt key database for a somewhat larger amount of PPAs. Apr 29, 2017 at 23:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .