If you have an old/insecure GPG/PGP key and want to upgrade, this blog post is for you. Such a key would be one using less than 2048 bits or using DSA encryption.

I decided that I need to change something about my GPG setup. I was still using a 1024bit DSA key from 2010 which means: Even if I create new and stronger subkeys, my signatures would forever be weak.

Since upgrading my old primary key was a non-trivial task, I'm writing this blog post for future reference by me or you.

First off: You cannot really upgrade a GPG primary key. You can create new subkeys which have stronger encryption, but those will be signed by the primary key. So holistically speaking, this is a bad situation.

If you want to get out of that hole, you'll have to:

  1. Create a new primary key
    • If you want more UIDs, create those as subkeys
  2. Sign your new key(s) with your old key
  3. Update local configuration files to use the new key for the future
  4. Update external services that might have your public key
    • For example Git forges
  5. Upload your new public key to key servers so it can be found/used by other people
  6. Create a revocation certificate
  7. Backup your keys
  8. Inform the people who signed my old keys that I've got a new one and kindly ask that they sign the new one, too

Steps 1 and 2

These are very good tutorials:

One suggestion that are not mentioned in these two links: Use an expiration date less than 2 years into the future. This acts as a 'dead mans switch'. As long as you have access to your private key, you will always be able to extend the expiration date - even if it has passed. If you do, it's prudent to also set a reminder to extend the expiration date in the future.

Step 3

I had to change configuration in:

  • ~/.gitconfig
    • Updated the signingkey under [user]
  • ~/.gnupg/gpg/conf
    • Updated the encrypt-to and default-key settings

Don't forget to change your MUA configuration, too. I'm using Mu4e (Mu 4 Emacs), you can find my configuration here. This is a good time to test some mails to yourself and see if signing/encryption works as expected.

I also had to make changes to other files you might not have. For example I'm using ~/.authinfo.gpg which holds server credentials (such as SMTP or IRC). I also have some other encrypted files which hold personal data. I decrypted all of those and re-encrypted them with the new secret key.

Step 4

Think of all applications you're using that might require a current PGP public key. Some could be:

  • Github
  • Gitlab
  • Keybase

Export your public key and add it to those applications:

gpg --export --armor [your_fingerprint]

Step 5

Upload your key to some keyservers - especially the ones that you've been using before. For example:

gpg --keyserver pgp-mit.edu --send-keys [your_fingerprint]
gpg --keyserver hkp://pool.sks-keyservers.net --send-keys [your_fingerprint]

Step 6

If you ever lose your secret key or it gets compromised in any way, it's good to have a revocation certificate handy. If you're using a 'newer' version of GnuPG (> 2.1), this happened automatically when you created a new key (step 1). You will find it in ~/.gnupg/openpgp-revocs.d/. If it's not there, create one using:

gpg --output revoke.asc --gen-revoke [your_fingerprint]

Step 7

It's important to back up your PGP keys - for example by printing a hardcopy.

Step 8

I looked up who signed my old key (gpg --list-signatures [your_old_fingerprint]) and sent those people an email. You can use mine as a blueprint:

From: Alain M. Lafon <alain@200ok.ch>
To: Alain M. Lafon <alain@200ok.ch>
Bcc: [everyone who signed my old key]
Subject: New PGP key

Dear fellow PGP user

After talking to some people more knowledgeable than me on GPG, I
decided that I need to change something about my GPG setup. I was
still using a 1024bit DSA key from 2010 which means: Even if I create
new and stronger subkeys, my signatures would forever be weak.
Therefore I decided:

- To create a new primary key
- Sign my new keys with my old keys to prove the identity behind the
new key
- Inform the people who signed my old keys that I've got a new one and
kindly ask that they sign the new one, too

Since you signed my old key, you're receiving this email. If you are
not interested in getting/signing my new GPG key, I deeply apologize
for the spam message - you can safely ignore this email and stop
reading here.

The old key will continue to be valid for some time, but I prefer all
future correspondence to come to the new one. I would also like this
new key to be re-integrated into the web of trust. This message is
signed by my new key which itself is signed by my old key to certify
the transition.

The old key was:

  pub   1024D/C5833B41 2010-12-08
       Key fingerprint = 79D6 2944 374F 5C7A A4DF  71CD E87B 13F0 C583 3B41

And the new key is:

  pub   4096R/8E1FC0E9 2019-07-17
       Key fingerprint = D465 337B 218A 0216 ECDC  368E 1370 99B3 8E1F C0E9

To fetch the full key from a public key server, you can simply do:

  gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-key 'D465 337B 218A 0216 ECDC  368E 1370 99B3 8E1F C0E9'

Alternatively, my old and new keys are on the following keyservers:

- http://pgp.mit.edu/pks/lookup?search=alain+m.+lafon&op=index
- http://hkps.pool.sks-keyservers.net/pks/lookup?search=alain+m.+lafon&fingerprint=on&op=index

I also uploaded the public key to my companies (200ok llc) website
with information on my fingerprint for additional insurance for you:
https://200ok.ch/team.html

If you already know my old key, you can now verify that the new key is
signed by the old one:

  gpg --check-sigs 'D465 337B 218A 0216 ECDC  368E 1370 99B3 8E1F C0E9'

If you are satisfied that you've got the right key, and the UIDs match
what you expect, I'd appreciate it if you would sign my key. You can
do that by issuing the following command:

  gpg --sign-key 'D465 337B 218A 0216 ECDC  368E 1370 99B3 8E1F C0E9'

I'd like to receive your signatures on my key. You can send me an
e-mail with the new signatures:

  gpg --armor --export 'D465 337B 218A 0216 ECDC  368E 1370 99B3 8E1F C0E9' | gpg --encrypt -r 'D465 337B 218A 0216 ECDC  368E 1370 99B3 8E1F C0E9' --armor

It's helpful to disable old keys to make sure that future
communication gets encrypted for the right key:

  $ man gpg2
  [...]
  A disabled key can not normally be used for encryption.
  [...]

  $ gpg --edit-key 79D62944374F5C7AA4DF71CDE87B13F0C5833B41
  [...]

  pub  dsa1024/E87B13F0C5833B41
  [...]

  gpg> disable

  gpg> save

Thank you very much for your time and consideration!

Best regards
Alain

Final words

If you want to get in touch, you can securely contact me using PGP(;

Fingerprint = D465 337B 218A 0216 ECDC 368E 1370 99B3 8E1F C0E9
Key ID = 0x8E1FC0E9
https://200ok.ch/pgp_keys/pubkey_alain.asc

Thank you Pascal Huber and Max Schrimpf for reading drafts of this!

Thank you Tomáš Pospíšek for recommending changes to the article!