First, pick a good password. There are a few websites on the Internet that help you generate strong passwords. Try and pick an alphanumeric password. Something such as Rv7fkcxASW8h would be a good choice.
Now check to see if you have the package gpg installed on your computer. Run the following command to check:
# whereis gpg
gpg: /usr/bin/gpg /usr/share/man/man1/gpg.1.gz
If you get an output like the one shown above it means you have the required package installed. If not, check your Linux distribution’s documentation to see how you can install the GPG package.
Say you want to password protect a file called dbbackup.zip with the password Rv7fkcxASW8h here’s how you would go about it:
# gpg -c dbbackup.zip
When you enter this you will be requested to enter a passphrase, which is the password you want to protect the file with. Enter the password twice. Now you should see a file called dbbackup.zip.gpg in the same directory as the original file. This is the encrypted and password protected copy of the original file. You can store this file on your hard drive or ship it to someone on a DVD knowing that it will be very hard and nearly impossible for most people to crack it.
When you want to read the file you will need to remove the password protected encryption. For that execute the following command:
You will be asked to enter the password using which the file was protected. Enter that and you should be in business. Note that this only works for files and not for folders. You should create a zip or tar archive of the files you want to secure and then add the password protected encryption to it.