Sign Your Repository
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.
dnfchecksrepomd.xml.ascwhenrepo_gpgcheck=1;aptchecksInReleaseorRelease.gpgagainst the key named inSigned-By. - RPM package signatures live inside each RPM.
dnfchecks them whengpgcheck=1, and they still hold after the file leaves your repository. DEBs have no counterpart: APT trusts package hashes through the signedRelease, 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
pigstystandard repository in the/srv/sowworkspace, from the YUM or APT tutorial. Run only the commands for the formats and Dists you created. - GPG, plus
rpmif 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.
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:
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:
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:
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:
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:
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:
Enable the checks that match what you signed:
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:
Reference it from the deb822 source and remove Trusted: yes:
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:
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.