Wednesday, October 6, 2010

Encrypt and decrypt files with a password in Linux

There are various ways to make a file password protected. Use one of the following commands to encrypt or decrypt files with a password.

  1. Use GNU gpg command
  2. Use mcrypt command
  3. Use openssl command

gpg Command

To encrypt and decrypt files with a password, use gpg command.

To encrypt single file:
gpg -c filename

This will ask for the pass-phrase and will create filename.gpg.

To decrypt file use gpg command:
gpg filename.gpg

To decrypt a file and write output to file output.txt you can run command:
gpg filename.gpg –o output.txt

No comments:

Post a Comment