1. Backup Your Current Keyring (Important!)
gpg --export-secret-keys > secret-keys-backup.asc
gpg --export > public-keys-backup.asc
2. Generate a New Strong Primary Key
gpg --full-generate-key
Recommended choices:
Key type: RSA and RSA (or Ed25519 for ECC)
Key size: 4096 bits
Expiry: 1y or 2y (renew later as needed)
Take note of your new key ID (gpg --list-keys).
3. (Optional) Generate Subkeys for Encryption, Signing, Authentication
To isolate duties (good for minimizing risk):
gpg --edit-key YOUR_NEW_KEY_ID
Then inside GPG prompt:
addkey
Choose each subkey type as needed:
Sign: Use for signing
Encrypt: Use for encryption
Auth: Use for SSH, etc.
Repeat addkey for
---
5. Set the Old Key to Expire
gpg --edit-key OLDKEYID
Then in the prompt:
expire
Set the expiration to something in the past or near future (e.g., 1d).
save
7. Upload New Key to Keyservers or Distribute
gpg --keyserver hkps://keys.openpgp.org --send-keys NEWKEYID
And revoke or update the old key as appropriate.