gpg command in Linux and it perimeters

gpg command in Linux and it perimeters

The gpg command in Linux is used for encryption, decryption, and digital signature operations using the GNU Privacy Guard (GPG) software. GPG is a free and open-source implementation of the OpenPGP standard, providing cryptographic security and privacy for data communication.

Here’s a table explaining some of the main parameters and options of the gpg command:

ParameterDescription
-eEncrypt data.
-dDecrypt data.
–signCreate a digital signature.
–verifyVerify a digital signature.
-rSpecify recipient(s) for encryption or verification.
-uSpecify the user ID to use for signing or decryption.
–armorOutput ASCII-armored data.
–outputSpecify the output file for encrypted, decrypted, or signed data.
–recipient-fileRead recipients from a file (used with -e).
–encrypt-toDeprecated; specify recipients for encryption (used with -e).
–batchEnable batch mode (no interaction).
–yesAssume “yes” for all prompts.
–versionDisplay the GPG version information.
–helpDisplay help information about the gpg command.

Now, let’s see some examples of how to use the gpg command:

  1. Encrypt a File:
Bash
gpg -e -r recipient@example.com -o encrypted_file.gpg file.txt

This command encrypts file.txt using the recipient’s public key with the email address recipient@example.com and saves the encrypted output to encrypted_file.gpg.

  1. Decrypt a File:
Bash
gpg -d -o decrypted_file.txt encrypted_file.gpg

This command decrypts encrypted_file.gpg and saves the decrypted content to decrypted_file.txt.

  1. Create a Digital Signature:
Bash
gpg --sign -u user@example.com -o file.txt.sig file.txt

This command creates a digital signature of file.txt using the private key associated with the user ID user@example.com and saves the signature to file.txt.sig.

  1. Verify a Digital Signature:
Bash
gpg --verify file.txt.sig file.txt

This command verifies the digital signature in file.txt.sig against the original file.txt. The signer’s public key must be available to verify the signature.

  1. Export Public Key:
Bash
gpg --armor --output public_key.asc --export user@example.com

This command exports the public key associated with user@example.com and saves it to public_key.asc in ASCII-armored format.

  1. Import Public Key:
Bash
gpg --import public_key.asc

This command imports the public key from public_key.asc into the GPG keyring.

Please note that GPG supports many more operations and options for managing keys, trust levels, keyrings, and keyserver operations. The examples provided above demonstrate basic usage for encryption, decryption, and signing. Always ensure you have a good understanding of GPG and key management to use it securely and effectively.

Total
1
Shares

Leave a Reply

Previous Post
umask command in Linux and it perimeters

umask command in Linux and it perimeters

Next Post
how to turn off standalone services in linux

how to turn off standalone services in Linux

Related Posts