Post

Update GPG key by changing email address

Describes step that are required when you need to modify existing GPG key (add/remove email, additional information)

List GPG keys

1
2
3
4
5
6
7
8
9
10
11
12
gpg --list-secret-keys --keyid-format=long
[keyboxd]
---------
sec   xxxx/xxx1 2023-05-14 [SC] [діє до: 2025-05-13]
      xxxx
uid                 [безмежна] github_1 <xxxx.xx1@gmail.com>
ssb   xxxx/xxxx2 2023-05-14 [E] [діє до: 2025-05-13]

sec   ed25519/<KEY_ID> 2024-06-02 [SC] [діє до: 2027-06-02]
      xxxx
uid                 [безмежна] github_2 <xxxx.xx2@gmail.com>
ssb   xxxx/xxxx 2024-06-02 [E] [діє до: 2027-06-02]

Add new UID to key:

1
2
3
4
5
6
7
8
gpg --edit-key <KEY_ID>

Real name: <name>
Email address: <email>
Comment: <comment>
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a passphrase to unlock the secret key for
user: "foo <xxxx.xx2@gmail.com>"

Trust new UID.

1
2
3
4
5
gpg> uid <new uid number>
gpg> trust
Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y
gpg> uid <new uid number>

Revoke old UID

1
2
3
4
5
6
gpg> uid <old uid number>
gpg> revuid
Really revoke this user ID? (y/N) y
Your decision? 4
Enter an optional description; end it with an empty line: <description>
Is this okay? (y/N) y

Export updated gpg key

1
2
3
4
5
6
gpg --armor --export <KEY_ID>
-----BEGIN PGP PUBLIC KEY BLOCK-----
.....
mDxxxxxxxxxxxaQP
=xxxxx
-----END PGP PUBLIC KEY BLOCK-----

After that upload GPG key to remote github server.

This post is licensed under CC BY 4.0 by the author.