How to fix the “NO_PUBKEY” GPG error on Ubuntu
The “NO_PUBKEY” GPG error occurs when a user adds a software repository or PPA to Ubuntu without adding the GPG signing key. Since Ubuntu’s software back-end takes security seriously, the system will not allow the user to install anything from the repository without this key, and so this error appears. Luckily, it is easy to fix.
Have dependency errors on Ubuntu? Here’s how you can fix them.
Fix “NO_PUBKEY” GPG error – GUI
On Ubuntu Linux, it is possible to fix the “NO_PUBKEY” issue with the GUI. To start the process, press the Win key on the keyboard. Pressing this button will bring up the search box in Gnome on Ubuntu. From there, start typing “Software & Updates” in the search box. Then, click on the icon with that name. Or, if you can’t find it, select the icon with the brown box/globe.
Once the “Software & Updates” app window is open on the screen, look through the different tabs in the app, and click on “Authentication.” Clicking on the “Authentication” tab will take you to the “Trusted software providers” area.
Keep the “Software & Updates” area open, and open up a new browser tab. Then, head over to the page where you got the software PPA from. On this page, look for the GPG signing key and save it to your computer.
Once on the Launchpad page, click “technical details” to reveal the signing key, click on the key link to go to the next page.
On the next page, click on the link next to “pub,” to reveal the key in the browser.
Press Ctrl + S on the keyboard to save the file as key.
After saving the key to your Ubuntu Linux PC, go back to the “Software & Updates” app, in the “Authentication” section. Then, in the “Authentication” section, look for the “Import Key File” button.
Click the “Import Key File” button with the mouse to bring up a file browser window. Then, look through the file browser window to add the key file to Ubuntu.
When the key file is added to Ubuntu, you’ll be able to install software from this software repository. However, before you attempt to install software from this repository, you need to refresh Ubuntu’s software sources.
To refresh Ubuntu’s software sources, click the “close” button. When you do, a message will appear that says, “The information about available software is out of date.” Click the “Reload” button to refresh. Once refreshed, the error “NO_PUBKEY” will go away.
Fix “NO_PUBKEY” GPG error – command-line
The “NO_PUBKEY” GPG error can be fixed in the terminal, along with being fixed in the GUI. Some would argue that fixing this error in Ubuntu through the terminal is faster.
Open up a terminal window on your Ubuntu Linux PC by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Then, once the terminal window is open, use the update command to Ubuntu’s software sources, as we need to reproduce the error.
Upon running the update command, you will see a message that states, “The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY.”
Following the “NO_PUBKEY” message, you will see a number. Highlight this number with the mouse and copy it to your clipboard. This number is important, as it can be used with a recovery command to automatically import the missing GPG key to your Ubuntu Linux system.
With the number saved to your clipboard, type out the following command in the terminal window. Be sure to replace the “COPIED-NUMBER-HERE” portion of the command with the number copied to the clipboard on your Linux PC.
Note: To use the paste feature in the Linux terminal, press Ctrl + Shift + V on the keyboard.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys COPIED-NUMBER-HERE
Let the apt-key command run, and it’ll download the missing GPG key directly from the internet. When the command finishes, you’ll see a message that says “public key “REPO NAME Singing Key imported”.
After successfully importing the missing GPG key into Ubuntu, the “NO_PUBKEY” error is taken care of. However, the fix is not complete, as Ubuntu’s software sources must be refreshed to reflect the changes made by importing the key.
To update Ubuntu’s software sources, you must use the update command.
sudo apt update
When the update command finishes running, everything should be in working order!
Prevent “NO_PUBKEY” errors on Ubuntu
The “NO_PUBKEY” error is easy to avoid. To ensure that you do not run into this problem on your Ubuntu Linux PC again, do the following.
- Do not install any third-party software repository that does not provide a public key file.
- Only add PPAs to Ubuntu through the terminal. By adding PPAs through the terminal, the key file is automatically added to the system, avoiding the “NO_PUBKEY” issue.
- Never edit the software sources file to add in a third-party software repository to Ubuntu.