Quick Tip: Fix Apt GPG error NO_PUBKEY

- Wednesday, February 22, 2023

In the Ubuntu (Debian) packaging world of Apt, the use of apt-key has been deprecated (other than apt-key del to remove keys).

I’ve run into errors like the following periodically, and have had to spend more time than I should reminding myself of how to fix the issue:

1
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://apt.releases.hashicorp.com jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DA418C88A3219F7B

A more thorough guide has been written, but for quick reference the key steps are:

  1. Add the GPG key into the recommended directory: /etc/apt/trusted.gpg.d/<filename>.(gpg|asc)
  2. EDIT the apt sources file (either /etc/apt/sources.list, or /etc/apt/sources.list.d/<filename>), and set the signed-by clause to use the new file:
    deb [signed-by=/etc/apt/trusted.gpg.d/<filename>.(gpg|asc)] https://apt.releases.hashicorp.com jammy main
    
Apt Linux Tip Ubuntu
Software