Thursday, 28 May 2026

Using gpg

Create gpg key pair

gpg --full-generate-key

You’ll be prompted: Key type: choose default RSA and RSA Key size: 4096 Expiration: e.g. 1y (or 0 for no expiry) User ID: Real name (e.g. Your Name) Email (e.g. you@example.com) Comment (optional) Confirm and set a passphrase

Encrypt a file

//recipient email is the same email used to create key pair
gpg --output test.txt.gpg --encrypt --recipient you@example.com test.txt

Decrypt a gpg file

gpg --output test-decrypted.txt --decrypt test.txt.gpg

Encrypt a file using fingerprint

Step 1: find public key fingerprint

gpg --list-keys

See something like the following in the out put

pub   rsa4096 2026-05-28 [SC] [expires: 2027-05-28]
      876Dweeueuurtrotooyotyoooepepepep35A6

Step 2: encrypt using fingerprint

gpg --output test.txt.gpg --encrypt --recipient 876Dweeueuurtrotooyotyoooepepepep35A6  test.txt