Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › APT

How to Add an External APT Repository With GPG on Ubuntu 22.04 (Jammy)

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On Ubuntu 22.04, add an external APT archive by storing the provider’s public signing key in a dedicated keyring, binding that key with signed-by in a repository-specific source file, and running sudo apt update. Use the provider’s exact Ubuntu 22.04 instructions for the key URL, archive URL, jammy suite, and components. Do not substitute a Debian suite, another Ubuntu release, or an unverified key.

What you are configuring

APT downloads repository metadata and packages, then verifies their signatures before accepting them. An external repository therefore needs two matching pieces of configuration:

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • A public key that can verify signatures made by the repository owner.
  • A source entry that tells APT where the archive is and which keyring is allowed to authenticate it.

The signed-by option connects those pieces. Instead of making a key trusted for every APT archive, it limits that key to the repository entry where it is named. This makes the arrangement easier to audit and reduces the consequences of trusting a key that should authenticate only one archive.

For a manually managed archive, put the key in /etc/apt/keyrings. A keyring delivered and maintained by a Debian package belongs in /usr/share/keyrings. In either location, the file must be readable by APT’s unprivileged _apt user.

Before you add the repository

  • Confirm that the provider explicitly supports Ubuntu 22.04, also called Jammy.
  • Copy the provider’s official public-key URL, repository URL, suite, and components exactly. A typical Jammy suite is jammy, but use the value the provider publishes.
  • Find the provider’s published fingerprint, preferably in documentation and an independent channel. A key copied from a forum or an unrelated repository is not a safe substitute.
  • Check whether the provider supplies an archive-keyring package. Such a package can deliver future signing-key rotations through APT after the initial trust bootstrap.
  • Decide whether the provider supplies an ASCII-armored key, normally ending in .asc, or a binary keyring, commonly ending in .gpg or .pgp.

How to add an external APT repository on Ubuntu 22.04

1. Create the dedicated keyring directory

For an operator-managed key, create the recommended directory and give the directory ordinary read and traversal permissions:

sudo install -d -m 0755 /etc/apt/keyrings

Do not put a manually maintained key in a global trust location simply because it is convenient. A repository-specific keyring in /etc/apt/keyrings makes the relationship visible in the source entry.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Download the provider’s public key

Use the download command and URL from the provider’s Ubuntu 22.04 instructions. The following form saves an armored key temporarily; set KEY_URL to that exact official URL before running it:

sudo wget -O /tmp/vendor.asc "$KEY_URL"

Downloading to a temporary file lets you inspect the key before installing it. If the provider publishes a binary keyring and documents that format, save it directly with a .gpg or .pgp name instead. Never change the URL to a key belonging to another release or product.

3. Check the key fingerprint before trusting it

Display the fingerprint from the downloaded key:

gpg --show-keys --fingerprint /tmp/vendor.asc

Compare the complete fingerprint with the value published by the repository owner or confirmed through an independent channel. Names and email addresses in a key are not enough to establish identity; the fingerprint is the value you should match. If it does not match, stop, remove the temporary file, and obtain the correct key from the provider.

4. Convert an armored key to a binary keyring

Ubuntu’s guidance for the traditional .list source-file format used by Ubuntu 22.04 and earlier supports a de-armored binary key. Convert the verified armored file as follows:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo gpg --dearmor --yes -o /etc/apt/keyrings/vendor-archive-keyring.gpg /tmp/vendor.asc

Make the resulting keyring readable by APT:

sudo chmod 0644 /etc/apt/keyrings/vendor-archive-keyring.gpg

If the provider already gave you a verified binary keyring, do not dearmor it again. Install or copy that file into the chosen keyring directory and apply a readable mode. A permission-restricted key can work for your interactive account while failing when APT drops privileges to _apt.

5. Create a repository-specific source file

Ubuntu’s external-archive convention is a separate file under /etc/apt/sources.list.d/. Use a name that identifies the provider and ends in .list. This example follows the documented syntax; replace the archive URL and components with the provider’s exact values:

echo 'deb [signed-by=/etc/apt/keyrings/vendor-archive-keyring.gpg] https://vendor.example/ubuntu jammy main' | sudo tee /etc/apt/sources.list.d/vendor.list

The important parts are:

  • deb selects binary packages.
  • signed-by=/etc/apt/keyrings/vendor-archive-keyring.gpg names one absolute keyring path for this archive.
  • https://vendor.example/ubuntu is the repository’s base URL in the example, not a URL to guess for a real provider.
  • jammy is Ubuntu 22.04’s suite. Use it only when the provider specifies it.
  • main is a component. Some providers publish different components or several components; copy their list exactly.

The keyring path in the source entry must exactly match the file you installed. A spelling difference, a moved file, or a second source line referring to a different keyring can prevent authentication.

6. Refresh APT metadata

Run an update immediately after adding or changing the source:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update

Read the complete output. A successful update should fetch metadata from the new archive without signature, suite, or permission errors. Do not proceed to install packages while APT reports that the archive cannot be authenticated. Fix the source, key, URL, or permissions first, then run sudo apt update again.

7. Install the provider’s keyring package when one is supplied

Some repository owners publish an ARCHIVE-KEYRING package. Ubuntu recommends this model because later signing-key changes can then be distributed through the package manager. The trust sequence matters:

  1. Bootstrap the repository with the provider’s documented key and a working signed-by entry.
  2. Run sudo apt update and verify that signatures are accepted.
  3. Install the provider’s keyring package using the package name and instructions it publishes.
  4. Follow the provider’s documented transition instructions if the package installs a new keyring or changes the source entry.

Do not install an unverified keyring package merely to silence an error. The initial key and source must be correct before APT can safely deliver updates to the trust configuration.

A complete Jammy configuration pattern

The following sequence shows the relationship between the files and commands without inventing a provider’s real key URL. Set KEY_URL to the official URL supplied for Ubuntu 22.04, and adjust the archive URL and components to the provider’s documentation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo install -d -m 0755 /etc/apt/keyrings
sudo wget -O /tmp/vendor.asc "$KEY_URL"
gpg --show-keys --fingerprint /tmp/vendor.asc
sudo gpg --dearmor --yes -o /etc/apt/keyrings/vendor-archive-keyring.gpg /tmp/vendor.asc
sudo chmod 0644 /etc/apt/keyrings/vendor-archive-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/vendor-archive-keyring.gpg] https://vendor.example/ubuntu jammy main' | sudo tee /etc/apt/sources.list.d/vendor.list
sudo apt update

In a real installation, the fingerprint check is a decision point, not a command to skip. Continue only when the displayed fingerprint is the one the repository owner has published.

Where should the GPG key go?

Keyring location Use it when Management model Required condition
/etc/apt/keyrings You download and maintain the key yourself. Operator-managed configuration. The key file and every parent directory must be readable or traversable by _apt.
/usr/share/keyrings A Debian package installs and updates the keyring. Package-managed configuration. The source entry must point to the exact installed file, with permissions that allow APT to read it.

Both locations are recommended for repository-specific keyrings. The distinction is ownership: do not place a manually maintained key where a package is expected to manage it, and do not edit a package-managed key behind the package manager’s back.

Why use signed-by instead of a global APT key?

Without a repository-specific binding, a key placed in a global APT trust collection can potentially authenticate packages from more archives than intended. signed-by changes the trust scope: APT uses the named keyring, or the fingerprints selected from it, for that source entry.

This does not make an unverified key safe. It only narrows where a trusted key can be used. You still need to obtain the key from the repository owner, verify its fingerprint, use the provider’s current key, and keep the keyring readable by APT.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not copy a key from a forum, reuse a key belonging to a different repository, or silently replace jammy with another distribution name to make an installation appear to work. A signature from the wrong key or metadata for the wrong suite is a configuration failure, not a warning to ignore.

Manual source files versus add-apt-repository

For a conventional external archive, a manually managed .list file plus signed-by gives you explicit control over the URL, suite, components, keyring path, and future auditing. Ubuntu 22.04’s add-apt-repository utility is convenient for PPAs and can write a complete source entry to /etc/apt/sources.list or /etc/apt/sources.list.d/. Its documented PPA workflow also downloads the PPA’s public key into APT’s keyring.

Situation Prefer Reason
A vendor gives an HTTPS archive, a signing-key URL, and a keyring package. Manual .list entry with signed-by. You can bind exactly one archive to its dedicated key and follow the vendor’s rotation instructions.
You are adding a Launchpad PPA supported by the utility. add-apt-repository, following the PPA’s Ubuntu 22.04 instructions. The utility is designed to add the PPA source and retrieve its public key.
You need a source entry whose suite or components are unusual. Manual file. You can inspect and edit every field instead of accepting an automatically generated line.
The provider changes its signing key through a package. Provider’s keyring package after bootstrap. APT can receive subsequent key updates through the package-managed keyring.

Whichever method you choose, inspect the resulting source files and remove duplicate entries for the same archive. Two entries with different Signed-By values are a common cause of update failures.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting APT and GPG errors

NO_PUBKEY or signature verification failure

APT cannot find a key that matches the archive signature, or the key it found is not the one that signed the metadata. Check all of these in order:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Confirm that the downloaded key came from the provider’s current official URL.
  2. Compare its full fingerprint with the provider’s published fingerprint.
  3. If the source is a Jammy .list entry and the download was armored, confirm that you ran gpg --dearmor.
  4. Check that the file named after signed-by= exists at exactly that path.
  5. Make sure the source entry points to the repository’s current suite and archive URL.
  6. Run sudo apt update again after every correction.

Do not “fix” NO_PUBKEY by importing an arbitrary key into a global trust store. That hides the relationship between the archive and its key and can trust the wrong signer.

“Conflicting values set for option Signed-By”

This means APT found more than one source line for the same archive, but the lines name different keyrings or fingerprints. Search both the main file and the snippets directory:

grep -R "vendor.example/ubuntu" /etc/apt/sources.list /etc/apt/sources.list.d/

Keep one authoritative entry and one intended keyring. Remove or edit stale duplicate lines, then run sudo apt update. If a provider has intentionally changed its key, follow its migration instructions rather than choosing one of two entries arbitrarily.

The repository has no Jammy suite

Stop and read the provider’s compatibility guidance. A repository that publishes only another Ubuntu release or a Debian suite is not made compatible by changing its suite name in your file. Using the wrong suite can produce missing packages, dependency conflicts, or metadata that was never tested for Ubuntu 22.04.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Permission denied or unreadable keyring

Check the keyring and its parent directories:

ls -ld /etc/apt /etc/apt/keyrings
ls -l /etc/apt/keyrings/vendor-archive-keyring.gpg

The _apt user needs to traverse the directories and read the keyring. A directory mode such as 0755 and a key-file mode such as 0644 are typical for a non-secret public key, provided your system’s security policy permits them. Correct the path or permissions, then rerun sudo apt update.

APT still shows stale metadata

APT does not automatically reread a changed source or keyring at every later command. Run sudo apt update after each source-file or keyring change. If the output still references an old URL or suite, inspect every file under /etc/apt/sources.list.d/ and the main /etc/apt/sources.list for a leftover entry.

The URL is reachable but metadata is rejected

Network reachability is not authentication. A reachable server can still return metadata for the wrong suite, an unsigned archive, or content signed by a different key. Compare the source line with the provider’s Ubuntu 22.04 instructions and verify the key fingerprint; do not bypass signature checking.

Maintaining the repository safely

  • Keep the source file’s suite and components aligned with the provider’s current Jammy documentation.
  • Watch for provider notices about signing-key rotation. A changed key should be installed through the provider’s documented migration or keyring package, not an improvised replacement.
  • Keep only the keyrings and source entries you still use. An abandoned external archive remains an unnecessary trust relationship.
  • After editing either the keyring or source file, run sudo apt update and resolve every authentication error before installing or upgrading packages.
  • Record which repository owns each keyring file. Clear naming such as vendor-archive-keyring.gpg makes later audits and cleanup safer than a generic filename.

Removing an external archive

When you no longer need an archive, remove or disable its source file and remove its dedicated manually managed keyring only after confirming that no remaining source entry refers to it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo rm /etc/apt/sources.list.d/vendor.list
sudo rm /etc/apt/keyrings/vendor-archive-keyring.gpg
sudo apt update

If the keyring was installed by a package, let that package manage its files and follow the provider’s uninstall instructions instead of deleting files underneath the package manager. Removing the source stops future metadata retrieval; it does not automatically remove packages already installed from that archive.

Quick verification checklist

  • The repository owner explicitly supports Ubuntu 22.04 (Jammy).
  • The key came from the owner’s official URL and its full fingerprint was checked.
  • An armored key was converted to a binary keyring for the Jammy .list entry.
  • The keyring is in /etc/apt/keyrings or, when package-managed, /usr/share/keyrings.
  • The source file is under /etc/apt/sources.list.d/ and uses an absolute signed-by path.
  • The URL, suite, and components exactly match the provider’s instructions.
  • The keyring can be read by _apt.
  • sudo apt update completes without signature, suite, URL, or permission errors.
  • Any provider-supplied archive-keyring package is installed only after the initial trust bootstrap succeeds.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

APTGPGLinuxrepositoriessystem administrationUbuntu 22.04

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.