4/17/10

How to encrypt and decrypt a file in Linux, password protected | Linux Operating System - Debian, Ubuntu, Fedora, Gentoo, Arch


Security is important, we all know, and to protect files in Linux Operating System machines is really easy.

The files can be password protected, so you can carry them in a flash memory, and if you loose the flash, you do not have to worry about your info, as it will not be readable.

To encrypt a file in Linux we will use, gpg which is parte of the GnuPG.

Syntax of gpg

gpg -c filename.ext  

Let's imagine we have a file called my-personal-info.txt

I want to encrypt with a password to protect the file, run this command.

gpg -c my-personal-info.txt

The output of the command is:

$ gpg -c my-personal-info.txt   Enter passphrase:   

Enter a good passphrase, be sure to remember it, and do not use an easy one.

Then you will get

Repeat passphrase:   

Now gpg has created an encrypted file called my-personal-info.txt.gpg, the original file is still there, so you may want to erase it, or only transport the encrypted one, or send by email the encrypted one.

To decrypt a file just enter this command.

gpg my-personal-info.txt.gpg

You will be asked for the password or passphrase, and the file will be recreated.

Protect your data.

Posted via web from bithacker's posterous

No comments:

Post a Comment