GPG Key

Introduction

GPG key is an encryption system of data that we want to encrypt. It uses two pairing keys:

Setup in Fedora Linux

Note: You can do it also in Ubuntu distro using apt package manager or any operating system you want.

Requirements tools:

Use toolbox for isolating the GPG tool from the file system: toolbox create gpg

Install GPG inside the toolbox using dnf package manager: sudo dnf install gpg

Generate the new gpg key: Choose RSA1, Length: 4096. Insert your full name and email. Choose whether you want a key including expiration or not.

`gpg --full-generate-key 

Output Explanation

Note: This key that generated is for demonstrating and removed.

gpg: /var/home/username/.gnupg/trustdb.gpg: trustdb created
gpg: directory '/var/home/username/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/var/home/username/.gnupg/openpgp-revocs.d/09DB34F8680991262F26A92098C60C25F252A597.rev'
public and secret key created and signed.

pub   rsa4096 2026-06-06 [SC]
      09DB34F8680991262F26A92098C60C25F252A597
uid                      <Full Name> <Email address>
sub   rsa4096 2026-06-06 [E]

Find Your Key ID Using The Following Command:

`gpg --list-secret-keys --keyid-format=long`

Export Your Public Key

`gpg --export -a <your gpg id> > ~/my_public_key.asc

Export Your Private Key

This execution will require your master password (your passphrase):

`gpg --export-secret-keys -a <your gpg id> > ~/my_private_key.asc`

Export Your Revoke File

This file the revoke of the GPG key in case your PC is hacked or you lost your GPG key.

`gpg --output ~/my_cancel_key.asc --gen-revoke <your gpg id> 

Backup Using KeePassXC

Install KeePassXC directly in the file system and not in the toolbox

`flatpak install flathub org.keepassxc.KeePassXC -y`

The kdbk file that was created is the database file that includes the data.

In the left menu, Navigate to Advanced -> on bottom click Attachments -> Add the ASCII files: private, public and cancel files.

Note: Backup the kdbk file format in external storage or in the cloud.

Cancel The GPG Key

When your PC hacked or whether you lost your, This is how to cancel it and tell the world that this key is no longer available.

Create cancel file using readable ASCII file format: It will ask you if you want to do it and require to type your master password (Passphrase) of the GPG key. gpg --output ~/cancel_my_key.asc --gen-revoke <your key fingerprint>

Your key will be tagged as Revoked in your file system.

Declare To a Public Key Server

In order to tell the public key server that your key is revoked, You will tell it to keyserver.ubuntu.com or pgp.mit.edu

`gpg --keyserver keyserver.ubuntu.com --send-keys <your_fingerprine_key_string>` 

Validate The Revoked Key In The Key Server

../