Home > bash > encryption failed: Unusable public key

encryption failed: Unusable public key

Problem: gpg2 gives you an “Unusable public key” error when trying to encrypt a file.

gpg2 --output encrypted_file.gpg  --recipient <mykey> --recipient <other-guy's-key>  --encrypt file-being-encrypted.txt
gpg: <other-guy's-key>: skipped: Unusable public key
gpg: file-being-encrypted.txt: encryption failed: Unusable public key

In this case, the key had expired and needed to be refreshed.

A simple “gpg2 –refresh-keys” failed to run. So I opted to delete the key and try pull it down again.

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys <other-guy's-key>
gpg: requesting key <other-guy's-key> from hkp server keys.gnupg.net
gpgkeys: key <other-guy's-key> can't be retrieved
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
gpg: keyserver communications error: keyserver helper general error
gpg: keyserver communications error: Invalid public key algorithm
gpg: keyserver receive failed: Invalid public key algorithm

But when I tried again using an IP

gpg2 --keyserver  --recv-keys <other-guy's-key>
gpg: requesting key <other-guy's-key>8 from hkp server
gpg: key KEYID123: public key "Julius Ceasar <julius.ceasar@example.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Turns out that I need to update my gpg
For mac

$ brew upgrade gpg2

And now gpg2 works as expected without any issues.


Categories: bash Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: