Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Software] GPG keeps private key despite deleting it

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
User avatar
Onsemeliot
Posts: 338
Joined: 2010-12-15 14:43
Has thanked: 21 times
Been thanked: 5 times

[Software] GPG keeps private key despite deleting it

#1 Post by Onsemeliot »

I created my key pair many years ago and everything works fine using Debian 12 so far. Recently I created a new key pair for an other computer (using my system) and exported the private and public key in order to use it elsewhere. (It works fine there too.) Afterwards I deleted the key pair on my primary system because I don't need the public key from the other system. Nevertheless, I want to write encrypted emails to the other system. Therefore, I imported only the public key to my keyring. Surprisingly, the secret key keeps returning as soon as I import the public key.
I have checked several times that I didn't mess up the export files. (I in fact did import the public key and not by accident the secret key.)
When I am searching for secret GPG keys on my system in the command line I can find the second private key (that shouldn't even be there) after importing the public key. But when I attempt to delete it GPG claims that it doesn't exist. (I can also find it using the Seahorse/Passwords app and when I delete it there using the GUI it looks like it is gone. Even on the command line it doesn't show up any longer.) But each time I import the public key the secret key magically returns too.
Do you have an Idea what I could do to get rid of the somewhat obscure hidden secret key on my system?

Code: Select all

$ gpg --list-secret-keys
/home/user/.gnupg/pubring.kbx
-------------------------------------
sec   rsa4096 2010-01-01 [SC]
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
uid           [ultimate] Name <name@mail.com>
ssb   rsa4096 2010-01-01 [E]

sec#  rsa4096 2020-01-01 [SC]
      YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
uid           [ultimate] Name2 <name2@mail.com>
ssb   rsa4096 2020-01-01 [E]

$ gpg --delete-secret-key YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
gpg (GnuPG) 2.2.40; Copyright (C) 2022 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gpg: key "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" not found
gpg: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY: delete key failed: Not found

User avatar
cds60601
df -h | participant
df -h | participant
Posts: 750
Joined: 2017-11-25 05:58
Location: Florida
Has thanked: 138 times
Been thanked: 70 times

Re: [Software] GPG keeps private key despite deleting it

#2 Post by cds60601 »

I think (and very well could be wrong) all you really need to do is revoke the key and create a new key-pair.
Supercalifragilisticexpialidocious

User avatar
Onsemeliot
Posts: 338
Joined: 2010-12-15 14:43
Has thanked: 21 times
Been thanked: 5 times

Re: [Software] GPG keeps private key despite deleting it

#3 Post by Onsemeliot »

Thank you for your thoughts. But if I revoke the key I would need to replace it on the other system too. This would be a problem. Maybe I should instead just dump my whole key ring and create a new one. It seems you assume that this specific key is broken. I have to admit that I have encountered this behavior before. In this case I just did deal very cautiously and paid attention what I do. (I have created quite a few keys for coworkers because I usually set systems up for them.) It seems this is less related to this specific key but more a problem that occurs on my system. Maybe really my key ring is flawed.

User avatar
Onsemeliot
Posts: 338
Joined: 2010-12-15 14:43
Has thanked: 21 times
Been thanked: 5 times

Re: [Software] GPG keeps private key despite deleting it

#4 Post by Onsemeliot »

I did some more testing. The problem really seems to be with this key. I generated two new private keys that do not share this issue. I can delete the private keys and when I import only the public keys they actually are only the public keys afterwards.

Post Reply