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

Creating signed Form 15H file using pdftk and Drive app.

 I had invested in NCDs because there was no TDS on interest income on NCD. But from the current FY 2023-24 there is TDS on interest on NCD....