~/GPG CLI Quickstart Tutorial

Feb 15, 2023


This guide covers GPG basics for encryption and signing files using the command line.

Key Generation

To generate a new keypair, run:

1
gpg --full-generate-key

Follow prompts for key type, size, and your info.

Listing Keys

See all your keys:

1
gpg --list-keys

Exporting Public Key

Export your public key:

1
gpg --armor --export your@email.com

Encrypting Files

Encrypt a file for a recipient:

1
gpg --recipient someone@email.com --encrypt file.txt

Creates file.txt.gpg

Decrypting Files

Decrypt a file:

1
gpg --decrypt file.txt.gpg > file.txt

Signing Files

To sign a file:

1
gpg --armor --sign file.txt

Verifying Signatures

To verify a signature:

1
gpg --verify file.txt.asc

More on options at GPG Manual.

All commands can add --help for more info. Keep your private key safe.

Tags: [gpg]