GnuPG is a complete and free implementation of the OpenPGP standard

GnuPGJan 1, 2021 PDF

The GNU Privacy Guard

How to encrypt and decrypt a file:

# encrypt a file
gpg -e -r someone@domain.tld file-to-encrypt.txt

# decrypt a file
gpg -d -o secrets.txt file-to-encrypt.txt.gpg

# encrypt with a password only (no keys needed)
gpg -c file-to-encrypt.txt

# sign a file, and check a signature
gpg --detach-sign file.tar.gz        # creates file.tar.gz.sig
gpg --verify file.tar.gz.sig file.tar.gz

GPG Error: Unusable Public Key

If you encounter the following error:

There is no assurance this key belongs to the named user
encryption failed: Unusable public key

You can find a step-by-step solution here:

Fix: Unusable public key


Fix: “Unusable public key” error in GPG

Error message

If you encounter the following error, it usually means that no trusted public key is available:

There is no assurance this key belongs to the named user
encryption failed: Unusable public key

Cause

GPG refuses to encrypt because the public key is not trusted.

Solution

You need to mark the public key as trusted.

Step 1: List available keys

gpg --list-keys

Example output:

pub   ed25519 2026-04-09 [C]
      ABCDEFGHIJKLMNOPQRSTUVWXYX1234
uid           [ultimate] John Doe <John.Doe@domain.tld>

Step 2: Edit the key

Use the email address (or key ID) from the uid line:

gpg --edit-key John.Doe@domain.tld

Step 3: Set trust level

Inside the GPG prompt, run:

trust
5
y
quit

Step 4: Verify

After setting the trust level, GPG should be able to encrypt without errors.


Notes

  • Trust level 5 means “ultimate trust” and is appropriate for your own keys.
  • You can also use the key fingerprint instead of the email address for more precise identification.
  • Make sure the key has an encryption subkey ([E]) if you are using it with tools like pass.

Someone else’s key

Ultimate trust is meant for your own keys. For the key of someone else, check the fingerprint with that person, then sign it locally. GPG then trusts it, without making it “ultimate”:

gpg --fingerprint John.Doe@domain.tld     # compare this with the owner
gpg --lsign-key John.Doe@domain.tld

The same error also appears when a key has expired or has no encryption subkey. gpg --list-keys shows [expired] or no [E] line in that case; then the owner has to extend the key or make a new one.