Solution:
Root Cause: Missing Launchpad PPA Public Key in GPG Truststore
When adding a PPA or custom repository, APT checks the release file's cryptographic signature against keys stored in
/etc/apt/trusted.gpg.d/ or individual keyrings defined in
/etc/apt/keyrings/. If the signature was generated by a key missing from your system, APT throws the
W: GPG error: ... The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <KEY_ID> warning and refuses to trust package indexes.
# Diagnostic Verification:
Execute
sudo apt update and identify the 16-character hex string following
NO_PUBKEY (e.g.,
8C47BE8E75BCA694):
bash
sudo apt update | grep NO_PUBKEY
# Step-by-Step Fix:
1. Create the secure keyrings directory if it does not exist:
sudo mkdir -p -m 0755 /etc/apt/keyrings2. Export the missing key directly from the Ubuntu Keyserver using OpenPGP format:
gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys <KEY_ID>gpg --export <KEY_ID> | sudo tee /etc/apt/keyrings/ppa-key.gpg > /dev/null3. Alternatively, fetch directly via
curl in a de-armored binary format:
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x<KEY_ID>" | sudo gpg --dearmor -o /etc/apt/keyrings/ppa-key.gpg4. Ensure proper file permissions:
sudo chmod 644 /etc/apt/keyrings/ppa-key.gpg5. Update software sources and verify:
sudo apt update drop-in warnings should now disappear.# Prevention & Long-Term Monitoring:
Use add-apt-repository on modern Ubuntu releases (22.04 LTS and 24.04 LTS), which automatically handles key placement inside /etc/apt/keyrings/ without global trust escalation.