How to enforce `gpg --verify` to only consider `9F85796A16D64CC33CF084CA1E70BBC37279E5AB` public key?
`signature`: ``` -----BEGIN PGP MESSAGE-----
CENSORED -----END PGP MESSAGE----- ```
```bash cat signature | gpg --verify ``` ``` gpg: Signature made Wed 03 Jun 2026 01:04:52 CEST gpg: using EDDSA key 9F85796A16D64CC33CF084CA1E70BBC37279E5AB gpg: Good signature from "CENSORED" [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 9F85 796A 16D6 4CC3 3CF0 84CA 1E70 BBC3 7279 E5AB ```
Jun 2, 11:12pm
To enforce gpg --verify to only consider the specific public key 9F85796A16D64CC33CF084CA1E70BBC37279E5AB and reject all others, you can use the --keyring option to specify a custom keyring containing only that key. Here's how:
Step-by-Step Solution
1. Export the Specific Key to a Temporary Keyring
Extract the key 9F85796A16D64CC33CF084CA1E70BBC37279E5AB into a temporary keyring file:
--no-default-keyring: Ignores the default keyring.
--keyring ./temp-keyring.gpg: Uses only the temporary keyring.
3. (Optional) Clean Up
After verification, you can delete the temporary keyring:
bash
rm ./temp-keyring.gpg
Why This Works
By using a custom keyring with only the desired key, gpg cannot use any other keys for verification.
The warning This key is not certified with a trusted signature! will still appear (unless you explicitly trust the key), but the verification will only succeed if the signature matches the specified key.
Alternative: Use --trusted-key
If you want to trust the key for this session (and suppress the warning), you can use: