In this article we will try to teach you how to Encrypt Sensitive Files Using GnuPG on Linux. GnuPG (better known as GPG) is an implementation of a standard known as PGP (Pretty Good Privacy). It uses a system of “public” and “private” keys to encrypt and sign messages or data. GPG is an open source standard and a strong alternative to Symantec’s official PGP software. It was developed by Werner Koch and released in 1999 as an alternative to Symantec’s software suite of encryption tools. It is available as a free software download and is based on the Open PGP encryption standards set by the Internet Engineering Task Force (IETF).
This ensures that GPG is interoperable with Symantec’s PGP tools and with Open PGP standards. GPG allows users to open and decrypt files encrypted with PGP and/or Open PGP, which means it works well with other products. It also offers S/MIME and Secure Shell (SSH) support. Overall, GPG provides an interface for users to easily encrypt their files. Below we have mention the steps to Encrypt Files Using GnuPG on Linux distros.
How to Encrypt Files Via GnuPG on Linux
Install gnupg
Step 1: First check whether or not gnupg is already installed. Within terminal, run the command:
gnupg –version
Step 2: If it displays the version of gnupg you’re currently running (should be v2+), then you’re all set and can move to the next section. Otherwise, you can install gnupg by running:
sudo apt-get install gnupg2
Step 3: Once finished, check to ensure it’s installed:
gnupg — version
Generate a PGP Key
To create a unique key for encrypting and decrypting files with GPG:
Step 1: Make sure gpg-agent is running; on the command line, enter:
gpg-agent -s –daemon –write-env-file –use-standard-socket
Step 2: You will see something like the following (in which username is your IU username and Machine is the name of the system):
GPG_AGENT_INFO=/N/u/username/Machine/.gnupg/S.gpg-agent:22743:1; export GPG_AGENT_INFO;
Step 3: On the command line, enter:
gpg –gen-key
Step 4: You will see something like the following (in which username is your IU username and Machine is the name of the system):
gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.
gpg: keyring `/N/u/username/Machine/.gnupg/secring.gpg’ createdgpg: keyring `/N/u/username/Machine/.gnupg/pubring.gpg’ createdPlease select what kind of key you want:(1) RSA and RSA (default)(2) DSA and Elgamal(3) DSA (sign only)(4) RSA (sign only)Your selection?
Step 5: Enter 1 to select the default key.
Step 6: GPG will prompt you to choose a keysize (in bits). Enter 1024.
Step 7: Enter a value to specify how long the key should remain valid (for example, 2 for two days, 3w for three weeks, 10m for 10 months, or 0 for no expiration date).
Step 8: GPG will prompt you to confirm the expiration date. If the correct date is displayed, enter y.
Step 9: GPG will prompt for information it will use to construct a user ID to identify your key. At the prompts, enter your name, email address, and a comment.
Step 10: If the information displayed is correct, enter o to accept the user ID. To correct errors or quit the process, enter the appropriate alternative ( n , c , e, or q ).
Encryption Process:
Step 1: To encrypt a file using a GPG key you created, on the command line, enter (replace user_id with the email address you specified when you created the key and my_file with the name of the file to encrypt):
gpg -e -r user_id my_file
Step 2: GPG will create an encrypted version of the file you specified; the encrypted file will have a .gpg file extension (such as my_file.gpg). After confirming the encrypted version has been created, you can delete the original unencrypted file.
Final Words
We hope our article on how to Encrypt Sensitive Files Using GnuPG on Linux will help you and resolve all your problems. Because GPG follows the Open PGP standards, it offers users free, easy-to-use file encryption. It also provides the tools needed to allow users to interact with a GUI or command line to integrate encryption with email and operating systems like Linux. If you also want to know how to Encrypt files via GnuPG on Linux distros then follow the steps mentioned above.
I hope you understand this article, how to Use GnuPG to Encrypt Files on Linux.