Sub topic 3
Repositories and Signature Verification
Prerequisites and the trust model
This chapter assumes you can use a Linux shell and sudo, understand basic packages and repositories, and can read systemd service status. The commands apply to Debian or Ubuntu systems using apt and to RHEL-family systems using dnf.
A package repository is a server that publishes package files and metadata. Metadata describes available versions, dependencies, checksums, and repository information. A package manager downloads this information before it decides what to install.
Signature verification answers an important question: “Did this repository publish this metadata, and has it been changed since publication?” The package manager checks a digital signature using a trusted GPG key. HTTPS protects the connection, but repository signatures provide protection even when a mirror or network path is compromised.
Debian and Ubuntu repositories
APT reads repository definitions from /etc/apt/sources.list and files in /etc/apt/sources.list.d/. A source normally identifies a repository URL, a distribution release, a component, and optional signing-key settings.
Modern systems commonly keep repository keyrings in /etc/apt/keyrings. The signed-by option limits a repository to a particular keyring instead of trusting every key known to APT.
grep -R --no-filename \
-E '^[[:space:]]*(deb|deb-src)[[:space:]]' \
/etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null
apt-cache policyWhen you run apt update, APT downloads signed InRelease files or a signed Release file with a separate signature. The release metadata contains checksums for the repository indexes. APT verifies the signature, then uses those checksums when downloading package indexes and packages.
RHEL-family repositories
DNF reads repository definitions from files in /etc/yum.repos.d/. Important settings include:
| Setting | Purpose |
|---|---|
| `baseurl` or `mirrorlist` | Selects where repository content comes from |
| `gpgcheck=1` | Verifies RPM package signatures |
| `repo_gpgcheck=1` | Verifies repository metadata when supported |
| `gpgkey=` | Identifies a key that can verify repository content |
You can inspect enabled repositories and their configuration with:
dnf repolist
dnf repoinfo
grep -R -E '^\[(.+)\]|^(baseurl|mirrorlist|gpgcheck|repo_gpgcheck|gpgkey)=' \
/etc/yum.repos.d/DNF uses signed repository metadata and checks the GPG signature on an RPM before installation. On a newly enabled repository, DNF may ask whether to import its key. Confirm that the key belongs to the expected operating-system vendor or repository provider before accepting it.
Practical trust decisions
Use official distribution repositories when possible. For a third-party repository, verify its documentation, key fingerprint, supported release, and reason for enabling it. A repository designed for a different distribution release can produce dependency conflicts or replace core packages.
Keep repository definitions under configuration management. Review changes to repository URLs and signing keys like code changes. A valid signature proves that content matches the holder of the trusted key. It does not prove that the repository is safe, well maintained, or appropriate for your server.
Exercise
Why is disabling signature verification a poor fix for a repository error?
Show answer
It removes the check that detects altered or unauthenticated metadata and packages. The correct fix is to verify the repository configuration and install the expected trusted key.