Sunday, August 17, 2008

How to password protect a file on Linux?

This question is being asked by many Linux users on various forums. Today I searched on Google and found this solution on Linuxforums.org.

You can password protect a zip file. Proceed as follows:

Create a directory for this experiment, and name it test.
Copy a few files and paste them into this directory so it isn't empty.Now open a terminal and enter:$ zip -e -r test test
Enter password:Verify password:Delete the directory test.

Now you have a file test.zip which is password protected.
zip with -e option encrypts the contents of the zip archive using a password. This encrypts with standard pkzip encryption which is considered weak.

However, the job of protecting the file is done, because even the root user needs the password or should be a hacker to decrypt.

I also recommend the method suggested in the comments.
If the filename is test,
$ gpg --symmetric test
It will ask the password and create a file test.gpg
Delete the file test.

Use the following command to open the file:
$ gpg test.gpg
It will ask the password and create the test file.

1 comment:

Alan Haggai Alavi said...

The same can be done using gpg. However, it is much more powerful.

gpg --symmetric secret.file

Air India direct flight to San Fransisco has flown through China today.

 My sister in law left for San Fransisco by AI 173 flight which flows over North Pole. I tracked that flight on flightstats.com till it land...