Tags Archives: password protection

How to Password Protect a Folder into a Compressed Password Protected Archive File

There are numerous ways to encrypt a file or a directory under Linux.

 

Some of these methods involve deploying specific encryption utilities or public/private key systems such as gpg.

 

I wanted to deploy a simple method that relies on mainstream tools which are usually present on most if not all Linux systems.

 

The method described below uses tar and zip/unzip.

 

 

Create a Tar Archive

 

 

First, tar the folder into a .tar archive:

 

eg

 

tar -cvf folder.tar /folder

 

 

Create a Password Protected Compressed File using zip

 

 

then zip the .tar file:

 

zip -re folder.tar.zip folder.tar

 

it will prompt you to enter a password of your choosing and then verify it

 

 

HOWEVER, note it will still be possible to display a file listing of the contents of the .zip file.

 

 

To conceal the contents, you next need to place this created zip file in another folder and then zip compress this folder in turn, also applying password protection. 

 

The contents of the zip archive file will then be fully password-protected.

 

 

 

To Unzip

 

 

to unzip you have to use

 

unzip <zip.file>

 

This will prompt you to enter the password

 

unzip folder.tar.zip

 

 

 

Untar

 

tar -xvf folder.tar

 

this then recreates the directory structure and the contents

 

Continue Reading