#!/linuxSucks/Generate a GPG Key Pair

Mar 08, 2026

GnuPG (GPG) problably is installed already in your linux disctro

Install with your packages manager

sudo pacman -S gnupg
sudo xbps-install -S gnupg2
sudo apt install gnupg

Generate a GPG Key Pair

Run the following command in your terminal:

gpg --full-generate-key

Follow the instructions:

- Key type (e.g., RSA and RSA)
RSA (default)
- Key size (e.g., 2048 or 4096 bits)
Choose 4096 bits for maximum security
- Key expiration (e.g., never or after a set time)
Press Enter to set the key to never expire, or specify a duration (e.g., 2y for 2 years)
- User ID (name, email, and optional comment)
Enter your real name, email address
- Passphrase (to protect your private key)
Create a strong, memorable passphrase (password)

After you complete these steps, GPG generates the key pair and stores it in your keyring.

The final output in the terminal confirms the creation, for example:

pub   rsa4096 2026-03-08 [SC]
      3AA5C34371567BD2F5B94A730D636A18815046C1
uid                      jhondoe <jhondoe@darknesscode.xyz>
sub   rsa4096 2026-03-08 [E]

Verify and Export Your Key

List your keys to confirm creation:

gpg --list-secret-keys --keyid-format LONG

The output will be something like:

sec   rsa4096/3AA5C34371567BD2 2016-03-10 [SC]
      5538B0F643277336BA7F0E457FFFC09ACAC05FD0
uid                      jhondoe <jhondoe@darknesscode.xyz>
ssb   rsa4096/4BB6D45482678BE3 2016-03-10 [E]

Your key ID (e.g., 3AA5C34371567BD2)

Home  Linux  Notes  Blog Spot