GnuPG (GNU Privacy Guard) is a free implementation of the OpenPGP standard that allows you to encrypt and sign your data and communications. It's a powerful command-line tool used for:
brew install gnupgsudo apt install gnupgchoco install gnupgVerify installation by running gpg --version in your terminal.
This interactive tutorial will teach you essential GnuPG commands through hands-on practice:
Each step includes detailed instructions, example outputs, and real-time validation of your work.
First, we need to create a PGP key pair using GnuPG. We'll use the full key generation command for more control over options.
gpg --full-gen-key1 for "RSA and RSA"
(most compatible)4096 for maximum security
(when prompted)0 for no
expiration (for practice purposes) yo for "Okay"gpg --list-keys The output should look something like this:
Now let's export your public key so others can use it to encrypt messages to you and verify your signatures.
gpg --armor --export your-email@example.comReplace "your-email@example.com" with the email address you used when creating your key. The --armor flag outputs the key in ASCII format instead of binary.
Now let's encrypt a message using your public key. First, create a simple text file with a message.
This creates an encrypted file called message.txt.asc. Display it with: cat message.txt.asc
Now let's decrypt the message you encrypted in the previous step using your private key.
gpg --decrypt message.txt.ascYou'll be prompted to enter your passphrase. GPG will then decrypt and display the original message.
Now let's test encryption with a key provided by PGPractice. I'll give you a public key, and you encrypt a message with it.
Write any message you want! PGPractice will decrypt it and show you what you wrote to confirm encryption worked.
Now let's learn to create digital signatures and verify them. This proves authenticity and integrity.
gpg --verify signed-message.txt.asc