Adding a gpg key isn't working

When I try to add a gpg key to my account I get this error:

“keyring packet should only contain a single entity”

I’ve tried with both my personal key and my work key and get the same results.

You can see the key here -

And oddly enough when I paste the key from the keyserver instead of the one exported locally it works.

I had this probelm when trying to copy/paste keys created on Windows 10.

Sometimes exported keys get unwanted or unintended formatting.  Its best just to cat out the key and copy paste it directly from the Terminal.  That way (unless you have some custome setup for your terminal output) you can be sure that you are copying just the key in plain text, without any extra formatting or anything.

If you can’t cat the key and copy directly from Terminal, then I would suggest copy pasting your key into a text editor that is specifically designed for handling code.  This will make sure that they key is pasted in plain text and it will allow you remove any unwanted formatting.

If you don’t have a native program, you can use pastebin - you will just have to remember not to actually save your key, or at the very least delete it aftewards.

Its always probably a good idea to note that although my problem was created by Windows 10 - any system, even a Linux based one, can add weird formatting or characters to your key if you try opening it with native programs instead of directly copying from Terminal.

@bcl we’ve seen this before: the key probably exists twice in your local keychain and the export command copies both. The GitHub importer only sees that there are two keys, not that they are identical. Here’s your key after importing into a fresh keychain and exporting it, try this one.

1 Like

Ah, that could be. I was able to successfully import the one available from the Fedora keyserver, thanks!

The solution for me was specifying the key with the ID rather than the email address (as I have multiple keys with the same email address). For example:

$ gpg --list-secret-keys
$ gpg --export --armor --export-options export-minimal E2C9C068023C05F0 <-- Your key ID here