A matching checksum shows that two byte sequences match. A valid signature shows that a key signed those bytes. To identify who controls the key, authenticate its fingerprint through a separate trusted path.
The commands were tested on Ubuntu 24.04.4 with GNU Coreutils and GnuPG 2.4.4. Use the artifact name, digest file, signature, key, and fingerprint published by the actual upstream project.
Collect all four inputs
For a signed release, identify:
- the artifact, such as
project-1.2.3.tar.xz; - the upstream checksum file;
- the detached signature for the artifact or checksum file; and
- the expected full signing-key fingerprint from an independent official path.
Download from the project’s documented release location. A checksum copied from the same compromised server as the artifact can faithfully authenticate the attacker’s replacement. GnuPG’s own integrity instructions publish both release signatures and fingerprints to connect those steps 3.
Check the hash before opening the artifact
If the upstream manifest contains the exact local filename:
sha256sum --check project-1.2.3.sha256Expected success shape:
project-1.2.3.tar.xz: OKGNU sha256sum computes a SHA-256 digest and can check files against its digest
input 1. Preserve its exit status in automation:
if ! sha256sum --check project-1.2.3.sha256; then
printf '%s\n' 'checksum verification failed' >&2
exit 1
fiDo not continue after a mismatch, and do not “fix” the manifest to match the download.
Inspect the key without importing it
gpg --show-keys --with-fingerprint vendor-signing-key.ascCompare the complete fingerprint, not only a short key ID, with the fingerprint published through the project’s established documentation or another approved channel. A name and email inside an OpenPGP certificate are claims carried by the certificate; they are not independent identity proof.
Importing changes a keyring. For an isolated one-time check, create a separate GnuPG home:
Caution: The following commands write an isolated keyring under a fresh temporary directory. They do not alter the normal
~/.gnupgkeyring.
verify_home=$(mktemp -d)
chmod 700 "$verify_home"
gpg --homedir "$verify_home" --import vendor-signing-key.asc
gpg --homedir "$verify_home" --fingerprintRecheck the full fingerprint after import.
Verify the signature against the exact file
For a detached signature, name both inputs:
gpg --homedir "$verify_home" \
--verify project-1.2.3.tar.xz.asc project-1.2.3.tar.xzGnuPG’s verification command checks a signature against the signed data; the manual also distinguishes human-readable output from machine-readable status interfaces 2. A “good signature” means the bytes match the signature under that key. Treat trust warnings separately: the cryptographic signature can be valid while the key’s owner remains unverified.
For unattended distribution workflows, prefer a deliberately provisioned
keyring and gpgv, or parse GnuPG’s documented status output. Do not scrape
localized prose for the words “Good signature.”
The verified checksum lab
This bounded lab demonstrates what SHA-256 does and does not accept:
lab=$(mktemp -d)
printf 'release payload\n' > "$lab/release.bin"
(
cd "$lab" || exit 1
sha256sum release.bin > release.sha256
sha256sum --check release.sha256
printf 'changed\n' >> release.bin
sha256sum --check release.sha256
)
status=$?
printf 'final status=%s\n' "$status"The Ubuntu lab produced:
release.bin: OK
release.bin: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match
final status=1Ordering between the FAILED line and warning can vary because standard output
and standard error are separate streams. The decisive evidence is the nonzero
status after the bytes changed.
What each result establishes
| Check | Establishes | Does not establish alone |
|---|---|---|
| SHA-256 match | artifact bytes match the expected digest | who published that digest |
| Valid signature | artifact or manifest was signed by the corresponding key | who controls the key |
| Verified fingerprint | the key matches an independently trusted identifier | that the software is safe or suitable |
After verification, retain the artifact version, digest, signing fingerprint, commands, exit statuses, and observation date so another person can reproduce exactly what you checked.