About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When apt update prints "The following signatures couldn't be verified because the public key is not available:" followed by a line starting NO_PUBKEY, apt has found a signed repository but does not hold, or cannot use, the key that signed it. The fix is to obtain that key from the repository's owner, store it where apt expects it, and name it in the repository's Signed-By setting. Do not "fix" it by marking the repository trusted.
The line after the message is the word NO_PUBKEY and the identifier of the missing key. That identifier tells you which vendor's key to look for.
What the symptom means
apt checks the signature on each repository's Release data before it believes any package list. The apt source builds the message you see. It collects signatures it could not check because the key was absent, and prints "The following signatures couldn't be verified because the public key is not available:" followed by one entry per key. Each entry is the keyword NO_PUBKEY plus the hexadecimal key identifier that gpg reported.
A NO_PUBKEY line is not always a failure. A comment in the apt source says the check "is only fatal if we have no good sigs or if we have at least one bad signature", and that good signatures and NoPubKey signatures "happen easily when a file is signed with multiple signatures". If apt update finished and the repository updated, a NO_PUBKEY line alongside it may not need any action.
Other messages from the same code path mean different things:
| Message from apt | Meaning |
|---|---|
| "The following signatures couldn't be verified because the public key is not available:" | The signing key is not in any keyring apt is allowed to use for this source. |
| "The following signatures were invalid:" | The signature was checked and failed, or the key is expired or revoked, or the signature uses a weak algorithm. |
| "The repository '...' is not signed." | The Release data has no usable signature at all. |
| "Updating from such a repository can't be done securely, and is therefore disabled by default." | The notice that follows the unsigned-repository error. |
Where apt looks for keys
The sources.list(5) manual describes the Signed-By option: it requires a repository "to pass apt-secure(8) verification with a certain set of keys rather than all trusted keys apt has configured". It takes absolute paths to keyring files, which "have to be accessible and readable for the _apt system user". If no keyring is named, "the default is the trusted.gpg keyring and all keyrings in the trusted.gpg.d/ directory", and every key there is a valid signer for the repository.
The manual's recommended locations are /usr/share/keyrings for keyrings managed by packages and /etc/apt/keyrings for keyrings managed by the system operator. The apt-secure(8) manual adds two format rules: "ASCII-armored keys must use an extension of .asc, and unarmored keys an extension of .gpg". It also warns that earlier methods using --keyring file --import "no longer work with recent GnuPG versions", because recent GnuPG versions use a new internal format ("GPG keybox database").
Why apt-key is not the answer
The apt-key(8) manual (bookworm version) is titled "Deprecated APT key management utility". It states "Use of apt-key is deprecated, except for the use of apt-key del in maintainer scripts", and "apt-key(8) will last be available in Debian 11 and Ubuntu 22.04". The Ubuntu Server documentation says that although many third-party guides still use it, this "is no longer recommended". Keys added to the shared keyring are trusted for every repository, which is the opposite of what Signed-By does.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Repository added without its key | NO_PUBKEY plus a key identifier right after adding a source |
The key file named in Signed-By does not exist, or the source has none and the shared keyrings lack the key |
| Key saved in the wrong format or extension | Key file present, same message | Armored key saved as .gpg, or a binary key saved as .asc (apt-secure) |
| Key file not readable by apt | Key present, same message, works for root only | Permissions on the file or its directory; the sources.list manual says _apt must be able to read it |
| Key rotated by the vendor | Worked for months, now NO_PUBKEY with a new identifier |
The vendor's site announces a new key; the identifier differs from the old one |
| Key expired or revoked | "The following signatures were invalid:" with an expired-key line | The vendor's key page and the key file's details from gpg --show-keys |
| Key imported with a method new gpg cannot feed to apt | Old instructions followed, apt still complains | Key was imported with --keyring file --import; apt-secure says this no longer works |
Prove the cause before changing anything
- Copy the exact
NO_PUBKEYlines from theapt updateoutput. Each identifier is a key to find. - Find which source mentions the repository. The sources.list manual says
/etc/apt/sources.list.d/holds files ending in.listor.sources. Read the files there and the main/etc/apt/sources.list. Note whether the entry hasSigned-By:(the.sourcesformat) or[signed-by=...](one-line format). - If a
Signed-Bypath is present, check that the file exists and is readable by everyone:
ls -l /etc/apt/keyrings/ /usr/share/keyrings/
Look at the extension and the permissions.
- Print what the key file actually contains. The gpg manual says
--show-keystakes OpenPGP keys as input and "prints information about them in the same way the command --list-keys does":
gpg --show-keys /etc/apt/keyrings/vendor-archive-keyring.asc
Compare the key identifier and fingerprint with the vendor's published fingerprint, and read the expiry date.
- If the source has no
Signed-By, look in/etc/apt/trusted.gpg.d/and/etc/apt/trusted.gpg: apt then accepts any key in those places for the repository.
Example (illustrative): On app01, an administrator adds a vendor's repository at https://repo.example.com/debian and runs apt update. The output ends with the "public key is not available" message and one line, NO_PUBKEY followed by a hexadecimal identifier. The new file /etc/apt/sources.list.d/vendor.sources has Signed-By: /etc/apt/keyrings/vendor.gpg, but ls -l /etc/apt/keyrings/ shows no vendor.gpg: the key was downloaded as vendor.asc. Armored keys need the .asc extension. The administrator fixes the path in the source file to vendor.asc, and apt update succeeds.
Fix
Get the key from its owner, and check it
The Ubuntu Server documentation says the key "must be obtained from the third party entity; it should be available at the root of the repository’s URL, but you might need to contact them and ask for the key file". Use the vendor's own HTTPS page. Do not take a key identifier from a forum post and fetch it from a key server without checking the fingerprint against the vendor's site.
The commands that follow only write a key file. The key is inert until a Signed-By line names it, so the mark for the change sits on that step. The sources.list(5) manual names /etc/apt/keyrings but does not say that every release ships it, so check that the directory exists before writing into it.
For an ASCII-armored key, the Ubuntu documentation's example is shown with its directory changed to /etc/apt/keyrings, which the apt manuals recommend for operator-managed keys. Name the same path in Signed-By:
sudo wget -O /etc/apt/keyrings/externalrepo-archive-keyring.asc https://thirdpartyrepo.com/ubuntu/externalrepo-archive-keyring.asc
Then run gpg --show-keys on the file and compare the fingerprint with the vendor's published value before continuing.
To store it in binary form, the same documentation de-armors the key with gpg --dearmor, again with the new directory:
curl -fsSL https://thirdpartyrepo.com/ubuntu/externalrepo-archive-keyring.asc | sudo gpg --dearmor -o /etc/apt/keyrings/externalrepo-archive-keyring.gpg
For the binary file, Signed-By names the .gpg path.
-f makes curl fail on HTTP errors and -L follows redirects (curl manual), so a failed download is not saved as a key. The .list format used on Ubuntu 22.04 and earlier only supports the de-armored binary key; the .sources format accepts either.
Name the key in the source
In a .sources file, add one line, or correct an existing one:
Signed-By: /etc/apt/keyrings/externalrepo-archive-keyring.asc
In a one-line .list entry, put [signed-by=/path/to/key.gpg] after deb.
Disruptive step: this changes which keys apt trusts for the repository, and the next apt update and upgrades will read packages from it. Back out by removing the key file and the source entry (or restoring the file you edited). Packages already installed from that repository stay installed.
Replace an old shared-keyring key
If a key was added earlier with apt-key add, the apt-key manual says "Use of apt-key is deprecated, except for the use of apt-key del in maintainer scripts to remove existing keys from the main keyring", and lists del keyid as "mostly deprecated". Move the repository to Signed-By first, confirm updates work, and only then remove the old shared key.
Risk: removing a key from the shared keyring changes the trust for every repository that relied on it. Any other source without its own Signed-By that was signed by that key stops verifying and fails with the messages above. Remove a key with sudo apt-key del <keyid>, where the key ID is the one apt-key list shows. The bookworm apt-key manual is the last one read, and the manual says the tool "will last be available in Debian 11 and Ubuntu 22.04", so on a later release it may be absent. The apt-key(8) manual says a keyring "should be placed directly in the /etc/apt/trusted.gpg.d/ directory with a descriptive name and either "gpg" or "asc" as file extension". A key that has its own file in that directory is removed by moving that file somewhere else instead of deleting it, so you can put it back. A key added with apt-key add is different: the manual's FILES section says /etc/apt/trusted.gpg is the "Keyring of local trusted keys, new keys will be added here", so that key sits in /etc/apt/trusted.gpg together with every other key added that way, and moving that file would remove all of them. Do not move /etc/apt/trusted.gpg to remove one key. To back out, import the key again from the vendor and check its fingerprint.
A rotated or expired key
Vendors that ship a REPONAME-archive-keyring package let you update the key through apt, according to the Ubuntu documentation. Because that package is signed by the key apt lacks, the documentation says to download it manually the first time. Otherwise, repeat the fetch-and-check steps with the vendor's new key.
What not to do
The sources.list manual says the Trusted option set to yes "disables parts of apt-secure(8), and should therefore only be used in a local and trusted context (if at all) as otherwise security is breached". Adding trusted=yes removes the check that tells you a repository was tampered with.
Confirm the fix
- Run
sudo apt update. The "public key is not available" message is gone for that repository. - Simulate installing a package from that repository with
sudo apt-get -s install <package>. The-soption simulates the install, so nothing is changed, and the run shows whether apt can read the repository. - Re-run
ls -lon the key and confirm it is readable by everyone and has the right extension.
What to watch afterwards
- Record each third-party repository, its key file, its fingerprint and the vendor page where the fingerprint is published.
- Check each key's expiry on the vendor's page ahead of time. An expired key produces the "invalid signatures" message, not this one.
- Prefer vendors that publish an archive-keyring package, and install it.
- After restoring or cloning a server, check the keyring files came back with the right permissions.
Read next
Related articles you may want next.
- Troubleshooting"Could not get lock /var/lib/dpkg/lock-frontend": find the process holding itapt says Could not get lock /var/lib/dpkg/lock-frontend? Find the process holding it, wait for unattended upgrades and never delete the lock file.Read article
- Backup & RecoveryChecking a restored Linux server against its package records: rpm --verify, dpkg --verify and debsumsUse rpm --verify, dpkg --verify and debsums to check a restored Linux server, read the output, and know what package checks cannot see.Read article
- Troubleshooting/boot is full and the kernel update will not install: remove old kernels the safe wayKernel update fails, /boot is full? Check df, keep the running kernel, remove old kernels with apt or dnf, and fix the half-installed package.Read article
Risks and limits
- These commands have not been run or lab-tested. They come from the apt source, manual pages and Ubuntu documentation in the Sources list.
- The
NO_PUBKEYline format is read from the apt source. The exact prefix letters and wording of apt's surrounding lines ("W:", "E:") vary by command and release and are not quoted here. - Key identifiers and fingerprints must come from the vendor. No key identifiers or fingerprints are given here.
- Embedding a key inside a
.sourcesfile needs apt 2.4 or later, per the apt-secure manual. - This covers Debian-family systems. Red Hat-family repositories use
gpgkeyand different tools.
Sources
- apt source: methods/gpgv.cc — Debian apt project mirror, main branch, no date shown, accessed 18 November 2026
- apt source: apt-pkg/acquire-item.cc — Debian apt project mirror, main branch, no date shown, accessed 18 November 2026
- apt-secure(8) — Debian manpages, apt 3.3.8, source updated 2026-11-16, accessed 18 November 2026
- sources.list(5) — Debian manpages, apt 3.3.8, source updated 2026-11-16, accessed 18 November 2026
- apt-key(8) — Debian manpages, bookworm, source updated 2023-05-25, accessed 18 November 2026
- gpg(1) — Debian manpages, page date 2025-02-19, accessed 18 November 2026
- Third party repository usage — Ubuntu Server documentation, page shows "Last updated on Jul 02, 2026", accessed 18 November 2026
- curl manual page — curl project, curl 8.23.1, no date shown, accessed 18 November 2026
This article was originally published on .