Pages

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.
Post a Comment