You might see a missing public GPG key error (“NO_PUBKEY”) on Debian, Ubuntu or Linux Mint when running apt update / apt-get update. This can happen when you add a repository, and you forget to add its public key, or maybe there was a temporary key server error when trying to import the GPG key.
Source: Fix Missing GPG Key Apt Repository Errors (NO_PUBKEY) – Linux Uprising Blog
Quick’n’dirty solution:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys THE_MISSING_KEY_HERE
sudo
apt update 2>&1 1>/dev/null | sed -ne 's/.<em>NO_PUBKEY //p' |
while read key; do if ! [[ ${keys[</em>]} =~ "$key" ]]; then sudo apt-key
adv --keyserver keyserver.ubuntu.com --recv-keys "$key"; keys+=("$key");
fi; done
Yes, I know apt-key is being deprecated…