Skip to content

Sign Your Repository

Sign repository metadata and, optionally, RPM packages, then make dnf and apt reject anything you did not sign.

An unsigned repository trusts whoever controls the web server or the network path: a modified index or package installs without complaint. Clients close that gap with two independent checks, and you enable each one on its own:

  • Metadata signatures prove that the index came from you. The index records the checksum of every package, so a verified index also exposes a package that was swapped on the server. dnf checks repomd.xml.asc when repo_gpgcheck=1; apt checks InRelease or Release.gpg against the key named in Signed-By.
  • RPM package signatures live inside each RPM. dnf checks them when gpgcheck=1, and they still hold after the file leaves your repository. DEBs have no counterpart: APT trusts package hashes through the signed Release, so DEBs need no package signature.
What is signed SOW output Client setting
RPM metadata repodata/repomd.xml.asc repo_gpgcheck=1
APT metadata InRelease and Release.gpg Signed-By
RPM package Embedded RPM signature gpgcheck=1

In this tutorial you create a dedicated signing key, sign the metadata of the pigsty repository, optionally sign its RPMs, and turn on verification in dnf and apt. Start with metadata signing, which covers both formats; add package signing when clients require gpgcheck=1. Signing model explains the mechanism.

You need:

  • The pigsty standard repository in the /srv/sow workspace, from the YUM or APT tutorial. Run only the commands for the formats and Dists you created.
  • GPG, plus rpm if you sign RPM packages.
  • A client host and a way to publish the repository to it; see Serve and publish.

1. Create a dedicated key

These commands create an unencrypted test key and export it to a private directory outside the public repository tree. For a protected key, see the password note in step 2.

SIGNING_UID='SOW Repository <repo@example.com>'
gpg --batch --pinentry-mode loopback --passphrase '' \
  --quick-generate-key "$SIGNING_UID" rsa3072 sign 2y

FPR="$(gpg --batch --with-colons --list-secret-keys "$SIGNING_UID" \
  | awk -F: '$1 == "fpr" {print $10; exit}')"
test -n "$FPR"

sudo install -d -m 0700 /srv/sow-secrets
sudo chown "$(id -u):$(id -g)" /srv/sow-secrets
gpg --batch --pinentry-mode loopback --passphrase '' --armor \
  --export-secret-keys "$FPR" > /srv/sow-secrets/repo-signing.asc
gpg --armor --export "$FPR" > /srv/sow-secrets/repo-signing.pub
chmod 600 /srv/sow-secrets/repo-signing.asc

SOW reads the private key from /srv/sow-secrets. If SOW runs under a different service account, give that account access to the directory. repo-signing.pub is what you distribute to clients.

2. Configure metadata signing

In /srv/sow/sow.yml, merge these entries into the repository’s existing signing block. Keep its package policy and Dist definitions, and include only the formats you use:

repos:
  pigsty:
    signing:
      rpm:
        metadata:
          key: file:///srv/sow-secrets/repo-signing.asc
      deb:
        metadata:
          key: file:///srv/sow-secrets/repo-signing.asc
    dists:
      # existing Dist definitions remain here

A protected key needs a password source before you check or build. Add passfile: /run/secrets/gpg-password next to key, run export SOW_GPG_PASSFILE=/run/secrets/gpg-password, or pass it for one invocation, as in sow build -r pigsty --passfile /run/secrets/gpg-password. The same works for agent://FINGERPRINT keys. The file holds the password itself on one line; keep it outside the repository, normally with mode 0600. sow.yml stores only the reference, never the secret. Password files gives the priority order and exact format; existing passphrase references keep working.

Validate, rebuild, and check:

cd /srv/sow
sow config check
sow build -r pigsty
sow check -r pigsty

A new key marks the affected Dists dirty, so build signs their metadata again. Metadata signing is in place when sow check passes: it verifies every metadata signature.

3. Optional: inspect the metadata signer

To see the signer with GPG, run the commands for your Dists:

gpg --verify \
  pigsty/dists/el9/x86_64/repodata/repomd.xml.asc \
  pigsty/dists/el9/x86_64/repodata/repomd.xml

gpg --verify pigsty/dists/trixie/InRelease
gpg --verify \
  pigsty/dists/trixie/Release.gpg \
  pigsty/dists/trixie/Release

The fingerprint shown must match the public key you distribute to clients.

4. Optional: sign RPM package bodies

SOW signs an RPM while add imports it and never re-signs packages already in the pool: build only checks stored RPMs against the policy. So in a new repository, configure package signing before you import RPMs. Add this block under the existing signing.rpm configuration:

repos:
  pigsty:
    signing:
      rpm:
        packages:
          mode: fill
          key: agent://REPLACE_WITH_THE_FINGERPRINT
        metadata:
          key: file:///srv/sow-secrets/repo-signing.asc

Replace the placeholder with the 40-hex fingerprint in $FPR. SOW signs through the host rpm command, so install rpm and gpg and make the secret key available in the GPG keyring that rpm uses.

fill signs each newly imported package unless its signature already verifies against the configured key or a key in trusted_keys. SOW verifies both RPM v4 and RPM v6 signatures; Signing model lists the formats, and the configuration reference describes the other modes. SOW signs a private copy, so your input file stays unchanged.

For a protected package-signing key, set passfile under signing.rpm.packages or use SOW_GPG_PASSFILE; a passfile under metadata applies only to the metadata key. config check validates the package-signing prerequisites but does not sign anything, so the password is first tested when an add actually signs a package.

If the pool already holds RPMs, check their signatures before you enable fill, and put trusted upstream public keys in trusted_keys. Unsigned or untrusted stored packages stay as they are: replace them with correctly signed packages that have new versions and file names, or configure signing in a new repository and import the originals there.

Import a new package and check the result:

sow config check
sow add /path/to/new.rpm -r pigsty -d el9
sow check -r pigsty

To inspect a signed package independently, run rpmkeys --checksig on its file in pigsty/pool/.

5. Enable DNF verification

First publish the signed repository. Then transfer the public key to the client through a trusted channel and import it:

sudo install -m 0644 /path/to/repo-signing.pub /etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty

Enable the checks that match what you signed:

[pigsty-el9]
name=Pigsty EL9
baseurl=https://repo.example.com/pigsty/dists/el9/$basearch/
enabled=1
repo_gpgcheck=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty

If you signed only metadata, use repo_gpgcheck=1 and gpgcheck=0. With package checks on, install the key of every upstream vendor whose signatures you kept, as well as your own. Then run sudo dnf makecache --refresh and install a package; both succeed only if the signatures verify.

6. Enable APT verification

After publishing the signed repository, install its public key on the client as a dedicated keyring:

sudo gpg --dearmor --yes \
  --output /usr/share/keyrings/pigsty-archive-keyring.gpg /path/to/repo-signing.pub
sudo chmod 0644 /usr/share/keyrings/pigsty-archive-keyring.gpg

Reference it from the deb822 source and remove Trusted: yes:

Types: deb
URIs: https://repo.example.com/pigsty
Suites: trixie
Components: main
Architectures: amd64
Signed-By: /usr/share/keyrings/pigsty-archive-keyring.gpg

On ARM64 clients, set Architectures to arm64. Run sudo apt update and install a package. If verification fails, compare the fingerprint of the client keyring with the signer gpg --verify reports.

RPM signing in a simple repository

In a simple repository, sow create can sign the RPM package bodies, but not the metadata, and a simple repository has no APT Release to sign:

sow create /srv/flat --sign-with 0123456789ABCDEF

Replace 0123456789ABCDEF with your key ID or fingerprint; the matching private key must be available to rpm and GPG. SOW keeps existing signatures, including upstream ones. To replace every signature with your key, add --overwrite on a separate working copy. For a protected key, add --passfile /run/secrets/gpg-password or set SOW_GPG_PASSFILE; a separate gpg command still needs its own credentials. See sow create for key formats.

For an existing YUM repository, the migration guide shows how to keep the publication timestamp and sign repomd.xml after the final create run.

Key changes

To rotate a metadata key, distribute the new public key to clients first, then update the key reference and run build, check, and publish. The changed key marks the affected Dists dirty.

For RPM package keys, use fill and keep the old public key in trusted_keys until the packages it signed are withdrawn or replaced; clients need the old key for that period too. Existing package objects never change. Signing model has the full rotation sequence.

Next

Test the final repository with the dnf and apt versions your users run; see Platforms & Integrations for what is covered automatically. Then serve and publish it.

Table reader