brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: gpg --verify checks a signature file against the file it signs

Linux
~/tips/tip-security-gpg-verify-detached-signature

gpg --import project-signing-key.asc

Verifies that a downloaded file matches its detached signature and was signed by the key you expect.

Some projects publish a .sig or .asc file next to the download. A checksum shows the file arrived intact, a signature also shows who made it.

gpg --import project-signing-key.asc
gpg --verify file.tar.gz.sig file.tar.gz

Give gpg --verify the signature first and the signed data second. The manual says the first argument should be the file with the detached signature and the remaining files should contain the signed data. Verifying with only the signature file is described as a strongly discouraged historical feature, so always name the data file.

Read the answer carefully. Good signature from followed by a name means the signature matches. You still have to check that the key fingerprint is the one the project publishes, because a signature from the wrong key is still a valid signature.

For scripts there is the smaller gpgv tool, used the same way: gpgv message.sig message.txt.

The caveat is about exit codes. The GnuPG examples say the program returns 0 if there are no severe errors and 1 if at least one signature was bad, and that using only the return code is not an appropriate way to verify a signature in a script. Use the status output or gpgv there. Also do not add --output when verifying a detached signature, because that produces an empty file.

Further reading: GnuPG: gpg(1) manual, GnuPG: GPG examples

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link