What the message looks like
W: GPG error: https://repo.example.com/debian stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1A2B3C4D5E6F7A8BCommon causes
- The repo key was never imported, typical after adding a new source.
- The key expired and the vendor rotated it.
- The keyring is not at the expected path, often after a distribution upgrade.
- An old source points to a repository that is signed differently now.
- The system clock is wrong, so valid signatures look expired.
Check
- Show the message and key ID
apt-get update 2>&1 | grep -B1 -A3 -i 'NO_PUBKEY' - Existing keyrings
ls -l /etc/apt/keyrings/ /usr/share/keyrings/ 2>/dev/null | head -n 20 - Check the system clock
date -u; timedatectl status | head -n 5 - Show the affected source
grep -rn . /etc/apt/sources.list.d/ | head
Fix
- Fetch the key from the repository vendor, not from a random keyserver:
curl -fsSL URL | gpg --dearmor -o /etc/apt/keyrings/repo.gpg. - Point the source at the keyring:
signed-by=/etc/apt/keyrings/repo.gpg. - For an expired key, check whether the vendor published a new one and update the source accordingly.
--allow-unauthenticatedor disabling signature checks is not a fix, it is a security hole.- Run
apt-get updateagain and read the full output.
Typical scenario
A tutorial from years ago recommends apt-key adv --keyserver ... --recv-keys for setting up a third-party repository. On a current Debian or Ubuntu apt-key is deprecated, and apt update still reports NO_PUBKEY with the key ID. The modern way is to put the key as a file into /etc/apt/keyrings/ and refer to it with signed-by= in the sources list.
FAQ
Can I ignore the warning?
No. Without a valid signature apt can install manipulated packages. Either get the key or remove the source.
Why does it appear after an upgrade?
Because new key paths and keyrings are used and old sources do not bring their key along.
How do I add a key correctly today?
Download the key from the vendor's site over HTTPS, convert it with gpg --dearmor and place it under /etc/apt/keyrings/name.gpg. The source file then contains [signed-by=/etc/apt/keyrings/name.gpg]. This way the key applies only to that repository.
May I fetch keys from a keyserver by ID?
Possible, but delicate: a key ID alone is easy to forge. It is better to load the key from the vendor's site and compare the fingerprint with the one in the documentation. Always verify before you trust a repository.
What distinguishes NO_PUBKEY from EXPKEYSIG?
With NO_PUBKEY the key is missing on the system, with EXPKEYSIG it is present but expired. In the second case you need the renewed version of the key from the vendor. apt does not let either case pass as trustworthy.