Search code examples
gnupg

How can I edit my private/secret gnupg key


Some years ago I changed my real life name. I then naturally want to change the names to my public and private GPG keys. I have managed to generate subkeys to my public keys with my new real life name, and I have managed to revoke subkeys with my previous name.

However: How can I change the name in the private key?

(I do understand that this actually does not matter much, since I'm not sharing this key with anyone anyway.)


Solution

  • There is no name stored in your private key. All UIDs are bound to the primary public/private key pair (by a special kind of signature). Add a new UID, make it primary and revoke the old one - you're done.

    $ gpg --edit-key [key-id]
    gpg> adduid   # Go through user ID assistant
    gpg> list     # Get list of UIDs
    gpg> [n]      # The number of the just added UID, probably "2"
    gpg> primary  # Set primary UID
    gpg> [m]      # The number of the old UID
    gpg> revuid   # Revoke that UID
    gpg> save
    

    Be aware that all incoming signatures (if you had any) point to the old UID, not the key; so you will be losing them anyway.