2

I'm trying to create an OpenPGP key with a photo ID using GnuPG and then export it, so it can be imported on a different computer.

Whatever tests I've done the photo ID never appears after the import on the new computer. As an example, I've started a virtual machine with no hard disk and a Linux Mint CD, then ran:

wget http://lorempixel.com/200/200/ -O test.jpg
gpg --gen-key # minimum options
gpg --edit-key -- -test-
# gpg> addphoto test.jpg
# gpg> save
gpg -K  # the photo is there

gpg --export-secret-key -- -test- > exported.secret.gpg
gpg --delete-secret-key -- -test-
gpg --delete-key -- -test-

gpg -K # verify nothing left:
gpg -k

gpg --import exported.secret.gpg
gpg -K

The photo is not there! How should this be done?

2
  • can you give some more information on your environment. and did the man pages / Documentation not cover how to do this? also, what steps (minus the key-material) have you taken to try this?
    – LvB
    Feb 4, 2016 at 9:17
  • I've been Googling / reading the man and tried --export-options export-attributes but this didn't help. Feb 4, 2016 at 10:40

2 Answers 2

2

The photo is on the public part of the key, so you need to export that, too:

gpg --export -test- > exported.public.gpg

Then import both keys again:

gpg --import exported.secret.gpg exported.public.gpg

And the photo is there.

1
2

Problem Analysis

You can verify what's contained in the export by piping into gpg --list-packets; I additionally grepped for the packet identifiers (starting with colons):

gpg --export-secret-keys a4ff2279 | gpg --list-packets | grep '^:'

Which from what the manual page says should list an atttribute packet like the following, but doesn't:

:attribute packet: [jpeg image of size 12899]

Setting the export option also doesn't:

gpg --export-options export-attributes --export-secret-keys a4ff2279 | gpg --list-packets | grep '^:'

This might or might not be expected behavior; attributes might be of large size, although it seems unexpected that user IDs are exported but attributes are not.

The Solution

I'd recommend to simply additionally export the public key, which contains all information on the key (but trust information):

gpg --export -- -test- > exported.public.gpg

And import this after importing the secret keys, similarly you did with the private keys (gpg --import exported.secret.gpg exported.public.gpg). The contents (also the missing user attribute packet and signatures it has) will be merged.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .