How to fix Debian Apt-get : NO_PUBKEY / GPG error
In computers based on a Debian operating system that uses Linux kernel, error messages similar to NO_PUBKEY may appear. This happens while using the Apt-Get command line tool, and this error is associated with the tool's update feature. This problem can be solved by simply keying in the appropriate commands.
To solve the Apt-get : NO_PUBKEY / GPG error in Debian, simply type the following commands, taking care to replace the number below with that of the key that was displayed in the error message:
gpg --keyserver pgpkeys.mit.edu --recv-key 010908312D230C5F
gpg -a --export 010908312D230C5F | sudo apt-key add -
sudo apt-get update
The problem should now be fixed. If you are missing multiple keys, then use this code:
sudo apt update 2>&1 1>/dev/null | sed -ne 's/.*NO_PUBKEY //p' | while read key; do if ! [[ ${keys[*]} =~ "$key" ]]; then sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys "$key"; keys+=("$key"); fi; done
That should fix multiple or single missing GPG keys.
Need more help with Linux? Check out our Forum!