INTRO

Recently, I saw a question of someone on Reddit. he wanted to know if is there any way to encrypt our directories. well, it was not easy to explain to him the method but somehow I did. then, I thought that I should share this advance method of making a password protected directory in just seconds.

Today, we are going to learn to make a password protected. but before going further, I would like to recommend to you some of my previous Articles.

Encrypt Any File

Encrypted Chat Server

Base64 Encryption

 

It is not necessary to take a look at these links. but you might get an idea about encryption/decryption and encoding/decoding after reading a little bit from there.  In the first one, I have explained about symmetric cipher algorithm and I tried to encrypt and decrypt an image using gpg tool.

 

SETUP

Note that we are not using gpg tool here and we can’t. gpg tool is used to encrypt a file. We are going to use a not very popular but useful tool named EncFS. It doesn’t come pre-installed in Kali Linux. so, we will need to install it.

∗Type this command to install EncFS:

apt-get -y install encfs

 

∗Now, we will make two directories named “.encrypted” and “decrypted“.

mkdir -p ~/.encrypted
mkdir -p ~/decrypted

 

We are making the encrypted directory hidden by adding “<strong>.</strong>” at first. user or anyone won’t be able to see it. but there will be some encrypted files and folders. the decrypted directory will show you the decrypted file and folders. By the way, you can name those directories whatever you want.

 

∗After that, we will run this tool:

encfs ~/.encrypted ~/decrypted

The first directory, we have specified is where all encrypted files and folders will be stored. and the second directory(decrypted) is where all decrypted files and folder will be stored.

once you do this, enter p for the pre-configured paranoia mode. then, it will ask you to set up a new password.

Output:

Creating new encrypted volume.
Please choose from one of the following options:
enter "x" for expert configuration mode,
enter "p" for pre-configured paranoia mode,
anything else, or an empty line will select standard mode.
?> p

 

∗Now, you can move all those files into decrypted dir which you want to be encrypted. I don’t know exactly but I think that EncFS tool creates his own file-system. that’s why we can see it as mounted file-system.

Type this command:

df -H

Screenshot:

∗You can unmount the decrypted folder whenever you want with this command:

fusermount -u ~/decrypted

Now, you won’t be able to see the content in the decrypted directory. if you take a look at .encrypted directory:

Output:

Ot8yyCHHWW5Fj,4dRRhDLShn CQ8k9,EiNPM,wNLeoY9g0OiJ/
NvPWue9GiLLCvo,d,zqKeYJj uv-OwnpWJyswLF8opNGxhB6LGvtwNdTOSIR7uiF6y2CN0-/
EInWde5VJpgv9wlAdS4BkjPI-zgU7w0UBu78I0C90,yAiHONn02NeztyYGIM8JRBTX0* HDNKKz4z,omPvwOvA4Kn5OpV/
Y7jTV-lDN,NuqmOi0YJU2mrOt5UiVu2qnEk6Sp4k0kj05, b1AmoSTDU7rkNi97aix9tyWs/
AGSthV04qEp0IV8g,H,FUStk TQoSHsiw3v8MQTlEq6rVxJ5hg6a0GDdf4NS1NsLjVPHQVrqfCHohVMcurht,eo5s154/
Fs1H7t6,xnvGfmTtsC,5aylK RETR6UnupYAgNo2xk4yOn8Hv/
MRWD0iCz3PvpjAC,eANzs6Yh 6AyQVzjBy70,R7epuHEexrcY/
ovrzmKhVf0NcGBlyV3su24Ibu0Lg,xLe4GH6S32QNEQLCeptro-5TH0IcV44Otp4WW- IhIbCEvlx4wrpCswVJGTwDDO/
Q9F0GZt,Qycz425M9FI3I3EsN2,1ujDcjWmMUtZX1Q1LH1 y5VJ6qjXsh9uli-hzd-7Gy4l/
EL5okJyZqtzcm6ukquhNtLgM2s9hCdJUZqYQfU8Gsjj4v- dEdhTdmubT-,qEVHT-NzFR,S/
y4VORXMFah-t,Tcfk3zcaH8h/ t0D54OG9KYt0K6rspa-zAFFQ/
Ka2-k8213skWdYuKncYy1YJO/ 17hzqpdicFFj-E9KX8qGqSUw/
y8Cl6FJf4nE-APjPP3zSIbaUTUOCYRKYoCeap2Y16kM5b,/ 4uGO4afEYz63tV0NvxjZEhww/
4j0g1nXiWXi8p7GIvmXn9pHn/ 6FPyillJ1903D2QmcA1bZH,J/
ZhvrEwaOO4JMoqNQlL-VlnVl/ ps-WdkaEFqxqiHKlObdDInWg/
2gKe-3T3lvIKADGbzXMOJal6/ HNBp9jfCLqLCL,DY52znzMqp/

As you can see that there are some directories that are fully encrypted. it is a funny thing that you can’t even see the name of the directories.

∗To decrypt these Directories again, type this command:

encfs ~/.encrypted ~/decrypted

But from now, you will have to provide a password every time you run this command.

WARNING- Don’t forget your password. there is no way to recover those files.

 

 

Stay home, stay safe and keep reading our articles.

Thanks For Visiting

LEAVE A REPLY

Please enter your comment!
Please enter your name here