Putting my gpg key on my yubikey
Why GPG?
In an age where digital identities are easily faked and impersonation is just a few clicks away, I decided to take a step forward in securing mine. GPG (GNU Privacy Guard) provides a robust way to authenticate, encrypt, and sign digital content. In this post, I’ll walk you through how I:
- Created a GPG key pair
- Set up subkeys and stored them on my YubiKey
- Published my public key on my website
- Signed and encrypted personal documents for secure public sharing
- Configured email signing using GPG
Step 1: Installing GPG
To start, I made sure GPG was installed. Here’s how I did it on each of my systems:
On Ubuntu/Debian:
On Fedora 40:
On OpenBSD 7.6:
Check your installation:
Step 2: Creating My GPG Key Pair
I created a new key using:
Here’s what I chose:
- Key type:
ed25519(modern and compact) orRSA and RSA(widely compatible) - Key length: 4096 bits (if RSA)
- Expiration: 2 years (I can always renew)
- My real name or handle
- My preferred contact email
- A strong passphrase, saved in a password manager
After generating the key, I listed it and saved the fingerprint:
Step 3: Creating Subkeys and Moving Them to My YubiKey
I created subkeys for:
- Signing
- Encryption
- Authentication
Then, I moved the subkeys to my YubiKey using GPG’s interactive editor:
⚠️ Be cautious: Once moved to the YubiKey, the subkey no longer exists on disk.
More guidance: YubiKey + GPG official instructions
Step 4: Publishing My Public Key
I exported my key in ASCII format so others could import it easily:
I uploaded publickey.asc to my website and linked it like this:
Additionally, I displayed my key’s fingerprint on the page so that people can verify its authenticity manually.
Step 5: Email Signing and Encryption
I configured email signing using my GPG key.
For Thunderbird (Linux, OpenBSD, Windows):
- OpenPGP support is built-in.
- I enabled signing for all outgoing mail.
- The key lives on the YubiKey, so no key is stored on disk.
For Mutt / CLI mailers:
- I used `gpg-agent` for passphrase and key handling.
- Configured
.muttrcto sign and/or encrypt automatically.
Signing ensures message authenticity. If recipients have my key, they can encrypt replies.
Step 6: Signing and Encrypting Documents for the Public
To safely share personal certificates and private files, I signed and optionally encrypted them:
This way, the document is verifiably mine and only decryptable with the shared password.
The encrypted .asc files can be uploaded to the website, with instructions for downloading and decrypting.
Step 7: Offline Backup of My Master Key
Before moving entirely to the YubiKey, I backed up the master key offline:
I stored it on an encrypted USB drive with either one:
- LUKS (on Linux)
- OpenBSD softraid(4) encryption
Conclusion
Rolling out GPG was super easy. With my identity cryptographically verifiable, email signing in place, and secure document sharing live on my site, I now have a strong, decentralized identity system.