Verify offline server releases with a separate trusted keyring
Running a SHA-256 check after moving a software package from a build environment to a dedicated server proves only that the file matches a particular checksum. If both the package and its checksum manifest have been replaced, the check will still pass. Offline delivery requires three separate checks: who approved the release key, whether that key signed the manifest, and whether the actual files match the manifest. This article tests that chain of trust without running any application code.
Define the trust boundary
This example is intended for Debian 12 and uses Bash, GnuPG, and GNU coreutils. Install gpg, gpgv, and sha256sum from an already trusted software repository before starting the offline exercise. No changes to networking, disk partitions, or running services are required.
The release side holds the private key; the receiving side holds only the approved public key. Verify the public key’s full fingerprint through an independent channel, such as an authenticated delivery record—not merely a text file supplied alongside the package. A short key ID is no substitute for the full fingerprint.
A checksum ties content to a digest, a signature ties it to a key, and an approval record ties that key to the publisher. None of these three layers can replace another.
The following exercise simulates release and receipt under the same account to reproduce the verification process. It does not provide real privilege separation. In production, use separate accounts or machines; the receiving side must not have access to the release private key. Do not use the lab key for real deliveries.
Prepare the lab materials
Run these commands in a single Bash session. The temporary directory uses private permissions to prevent other unprivileged accounts from replacing the lab files:
set -euo pipefail
umask 077
work=$(mktemp -d)
mkdir -m 700 "$work/signer" "$work/verifier" "$work/release"
gpg --homedir "$work/signer" --batch --pinentry-mode loopback \
--passphrase '' --quick-generate-key \
'Release Lab' ed25519 sign 1d
fpr=$(gpg --homedir "$work/signer" --with-colons \
--list-keys | awk -F: '$1=="fpr"{print $10; exit}')
printf '%s\n' "$fpr"
gpg --homedir "$work/signer" --batch \
--output "$work/trustedkeys.gpg" --export "$fpr"
printf 'release-lab-v1\n' > "$work/release/payload.txt"
(
cd "$work/release"
sha256sum payload.txt > SHA256SUMS
)
gpg --homedir "$work/signer" --batch --yes \
--local-user "$fpr" --detach-sign \
--output "$work/release/SHA256SUMS.sig" \
"$work/release/SHA256SUMS"
The short-lived key generated here has no passphrase and is for this exercise only. Production private keys need their own protection and signing approval process. payload.txt stands in for a delivered file; it is not software to be installed.
The exercise establishes trust by exporting the key directly. When receiving a real release, first inspect the candidate public key’s full fingerprint and compare it character by character with the approval record. Only then create a protected verification keyring. The delivery package must not be allowed to select an arbitrary keyring for itself.
Chain the two verification steps
Verify the manifest’s signature first, then check the files listed in the manifest. If either step fails, do not proceed to extraction, installation, or service restarts:
verify_release() (
set -euo pipefail
cd "$work/release"
gpgv --homedir "$work/verifier" \
--keyring "$work/trustedkeys.gpg" \
SHA256SUMS.sig SHA256SUMS || exit 1
sha256sum --strict --check SHA256SUMS || exit 1
)
verify_release
gpgv uses a separate directory and an explicitly specified keyring so that other public keys from the account’s usual environment are not included. It treats keys in that keyring as trusted. Adding a key to the keyring is therefore an authorization decision, not a harmless caching operation.
Deployment scripts should use exit codes to determine the result, rather than searching terminal output for a particular success word. Also avoid piping output to a logging command without enabling pipefail: a successful final command could otherwise hide an earlier failure.
Manifest verification covers only the files listed in the manifest. It does not guarantee that the delivery directory contains no extra files. This example explicitly delivers only payload.txt; a real workflow must likewise define a fixed file list rather than verify the release and then use a wildcard to install everything in the directory.
Test three types of tampering
First save a clean copy and define a check function that requires rejection. Change only one variable at a time so that the layer responsible for the failure is clear:
cp -a "$work/release" "$work/clean"
expect_reject() {
if verify_release; then
printf 'Unexpected acceptance\n' >&2
return 1
fi
printf 'Rejected as expected\n'
}
printf 'tampered\n' >> "$work/release/payload.txt"
expect_reject
cp "$work/clean/payload.txt" "$work/release/payload.txt"
(
cd "$work/release"
printf 'changed\n' >> payload.txt
sha256sum payload.txt > SHA256SUMS
)
expect_reject
cp "$work/clean/payload.txt" "$work/release/payload.txt"
cp "$work/clean/SHA256SUMS" "$work/release/SHA256SUMS"
truncate -s 0 "$work/release/SHA256SUMS.sig"
expect_reject
cp "$work/clean/SHA256SUMS.sig" "$work/release/SHA256SUMS.sig"
verify_release
The first test keeps the original manifest and changes only the file: signature verification can pass, but the checksum check must fail. The second changes both the file and the checksum manifest: although the checksum now matches again, the old signature must fail. The third empties the signature file: verification must reject the release outright, not fall back to checking checksums alone.
After all the original materials have been restored, verification should pass again. Also run a separate missing-public-key test: verifying the same signature with an empty, separate keyring must fail. If the workflow automatically fetches a key over the network and then continues deployment, it breaks the boundary established by prior key approval.
Gate every deployment path
Passing the exercise does not mean the delivery workflow is secure. Before going live, check four more requirements:
- Constrain the inputs. Allow only approved relative paths in the manifest; reject absolute paths and parent-directory traversal. Untrusted accounts must not be able to write to the working directory.
- Preserve the verified artifacts. Do not download a file with the same name again after verification. Place verified artifacts in a protected directory and ensure that installation uses those exact contents.
- Pin the version. A valid signature does not mean a release is current. Release records should retain the version and manifest checksum to prevent an older, legitimate delivery from being replayed as a new version.
- Retain the evidence. Keep the approved fingerprint, manifest, signature, tool versions, and exit statuses. Do not archive private keys or signing passphrases.
A signature on an archive proves only that the archive’s bytes are associated with the approved key. It does not establish that extraction paths, installation scripts, or program behavior are safe. Extraction checks and application acceptance testing remain separate requirements; a valid signature is not a reason to run scripts from the package directly with elevated privileges.
When rotating keys, approve the new fingerprint first, then update the verification keyring and retest the rejection paths. gpgv does not retrieve revocation information automatically, and offline verification keyrings also need updates through the approval process. If a key is found to be compromised, stop accepting its signatures and investigate the versions already delivered.
When finished, delete the lab directory created for this exercise while retaining acceptance-test records that contain no private keys. Success is not a “valid signature” message on the screen. It means legitimate deliveries pass, tampering at any layer blocks deployment, and no alternative deployment path bypasses verification.
Frequently asked questions
Is a software archive delivered with SHA-256 hashes enough?
No. An attacker could replace both the archive and its checksum manifest. Verify the manifest signature with an independently authenticated key before checking file hashes.
Can the public key shipped beside the release be trusted?
Not solely because it accompanies the files. Match its full fingerprint against a previously approved record, and approve key changes separately rather than accepting them automatically.
EPYC 7543P Dedicated Server
From $459.9/month