6

I have a GnuPG key pair with a master key (only Certify capability) and 3 subkeys (Sign, Encrypt and Authenticate capabilities respectively). Actually, when I start, I only have the private keys of the subkeys (I have a stub, marked with #, instead of the master private key)

I do as follows:

  1. I list private keys (gpg --list-secret-keys). There is a master key stub (#) an three subkeys.
  2. I encrypt a message with public Encrypt subkey (gpg -e USER)
  3. I decrypt the message (gpg -d): Ok.
  4. I delete de the three subkeys (gpg --edit-key). gpg --delete-secret-keys does not work on master key (it's only a stub) nor on the subkeys.
  5. I delete the public master key (gpg --delete-keys)
  6. I try to decrypt message from step 2: Not able, no private keys, Ok. I list private keys with gpg --list-secret-keys: No keys
  7. I kill gpg-agent (killall gpg-agent)
  8. I import public keys from key server again (gpg --receive-keys)
  9. I try to decrypt message from step 2 and surprisingly I am able to decrypt it by introducing the passphrase that protects the private subkeys! The private keys are there if I execute gpg --list-secret-keys again.

I guess I didn't delete correctly the private subkeys, I guess with the gpg --edit-key command I only deleted the public subkeys. Buy how can I delete the private subkeys if no master key is present (it's only a stub)?

After importing the secret master key again, I'm able to delete the master private key and his three subkeys by executing gpg --delete-secret-key. Is this the only option I have? Isn't it possible to delete secret subkeys if the master key is only a stub?

1 Answer 1

6

For GnuPG 2.1+, secret keys are stored in gpg-agent and only referenced by the main keyring.

Re-import the public subkeys again, then run gpg --list-secret-keys --with-keygrip. This will show the 'fingerprint' of the raw asymmetric key belonging to each subkey (do not confuse this with the fingerprint of the whole PGP subkey with metadata and all).

For each subkey that you want to delete, run:

gpg-connect-agent "delete_key <keygrip>" /bye
1

You must log in to answer this question.

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