+4 votes
296 views
How to put password folder Linux

in Linux / Unix by (551k points)
reopened | 296 views

1 Answer

+5 votes
Best answer

1. How to encrypt with a password a folder in Linux
2. How to encrypt a folder on Linux using Gnome Encfs Manager - Gnome Encfs Administrator
3. How to create a password to a folder on Linux using eCryptfs

As a general rule, all our files are stored in folders in order to keep a coherent and easily accessible order whenever it is necessary to go back to that particular file; but we should not overlook that many of these files are confidential or privately owned so we must avoid unauthorized access to them..

To protect our files hosted in a folder on Linux we can assign a secure password with which only we, or those who authorize, will have access to its content. Through this tutorial, TechnoWikis will explain how it is possible to assign a password to a folder on Linux operating systems.


1. How to encrypt with a password a folder in Linux


For this method, EncFS will be implemented which has been developed to provide an encrypted file system in the user space for UNIX systems. EncFS is executed in this user space making use of the FUSE library for the file system interface. We note that EncFS is an open source software, which is licensed under the LGPL license.

EncFS can encrypt files individually. This is achieved by translating all the requests from the virtual EncFS file system to the encrypted operations which are equivalent in the Linux file system.
EncFS creates a virtual encrypted file system which stores the encrypted data in the rootdir directory and allows the data to be visible without encryption in the mountPoint directory. The encryption with EncFs is good enough for most users who want to protect their folders in Linux..


2. How to encrypt a folder on Linux using Gnome Encfs Manager - Gnome Encfs Administrator


Gnome Encfs Manager, also called GEncfsM, is a utility which allows you to manage EncFS file systems in Linux, which has multiple unique features.
Step 1

For its installation first we must add the PPA repository with the following command:
 sudo add-apt-repository ppa: gencfsm 

image

Step 2

After this we proceed to update the repository packages by executing:
 sudo apt update 
Finally we install the utility by executing the following line:
 sudo apt install gnome-encfs-manager 
There we enter the letter "S" to allow the download and installation of the utility.

image

Step 3

During the process we will see the following message. There, click on "Accept" to continue the process.

image

Step 4

Once finished it will give us the opportunity to access the application from the application launcher of the system, in this case Ubuntu: image
Step 5

Once we access this application, this will be your environment. There we click on the + sign to add the folder to block which in this app is called stash.

image

Step 6

In the new window it will be possible to create a new directory or look for an existing one as well as add the password protection of an existing folder, but in this case we must bear in mind that the existing files will not be blocked, so that the best advice of TechnoWikis is to create a new folder and move the desired files there. Once we assign the password, we click on the "Create" button to execute the process.

image

Step 7

We will see that the volume is created and this will be reflected as a unit mounted on the desktop. There we can move the files we want to be protected. image
Step 8

In GNOME desktop environments we have an icon in the title bar where it will be possible to manage some tasks of the Gnome Encfs Manager utility. image
Step 9

When the process of copying the files to be protected has been completed, we can dismount the unit that has been mounted from the icon in the GNOME title bar or from the browser: image
Step 10

From the utility manager we can select the folder that we have blocked and by clicking on the configuration icon it will be possible to perform some tasks such as:
  • Set additional mounting parameters.
  • Access the file manager.
  • Show the menu and many more tasks.

image

So we can use this tool to assign a secure password to a folder using this handy utility.


3. How to create a password to a folder on Linux using eCryptfs


The eCryptfs utility is a file system that acts based on cryptographic methods compatible with POSIX for Linux environments. This eCryptfs utility stores cryptographic metadata in the header of each file, so that encrypted files can be copied between hosts and then these files can be decrypted using the key assigned in the Linux kernel ring.

eCryptfs has been built as a stacked file system which encrypts and decrypts files in the way they are written or read from the file system. eCryptfs is responsible for accessing the key material of the key set of the user session and makes use of the core cryptographic API to carry out the task of encryption and decryption of the contents of the file..

Step 1

To install eCryptfs in Linux we must execute the following command:
 sudo apt -y install ecryptfs-utils 

image

Step 2

There we enter the letter S to confirm the download and installation and although this utility is used in its greater percentage for the encryption of the home folder of the user we can implement it for a folder in space. For this we will create a folder called TechnoWikis1 using the following line:
 sudo mkdir / home / TechnoWikis1 
Note
In case of using an existing directory, if files are hosted in that directory it will be necessary to create a backup of them to be able to restore them to the encrypted directory / home / TechnoWikis1 and thus protect them, in this case we can execute the following:
 cp -pfr / home / TechnoWikis1 / / tmp / 

Now let's encrypt the / home / TechnoWikis1 / directory with the ecryptfs file system type by executing the following:

 sudo mount -t ecryptfs / home / TechnoWikis1 / home / TechnoWikis1 
First we will assign the password and then the type of encryption to be used will be displayed. The default value is AES so that there we press "Enter".

image

Step 3

Next we will select the amount of bytes to use in the encryption, for a greater security we enter the value 32. We press "Enter".

image

Step 4

In the next two questions we press "Enter" and finally we must confirm the assembly of that directory:

image

Step 5

We will see that the directory has been mounted correctly:

image

Step 6

It will be possible to execute the mount command to display the schema of the encrypted directory:

image

Step 7

To confirm that the encryption process is correct, we are going to copy the / etc / hosts directory to the path / home / TechnoWikis1 with the following line:
 sudo cp / etc / hosts / home / TechnoWikis1 
Then using the cat command we will see the contents of TechnoWikis1:
 cat / home / TechnoWikis1 / hosts 

image

Step 8

We proceed to disassemble the directory:
 sudo umount / home / TechnoWikis1 
If we try again to run cat / home / TechnoWikis1 / hosts we can see that its content is illegible:

image

There are other protection options such as Cryptkeeper but it is only available to old versions, such as Ubuntu 16, due to security failures that put the information to be protected at risk.

As we can understand, the security of information is a task to be taken very seriously and thanks to these Linux options it will be possible to protect in a simple but integral way.


by (3.5m points)
edited

Related questions

+3 votes
1 answer
+5 votes
1 answer
+5 votes
1 answer
asked Nov 15, 2019 in Linux / Unix by backtothefuture (551k points) | 620 views
+4 votes
1 answer
asked Aug 21, 2019 in Linux / Unix by backtothefuture (551k points) | 372 views
+3 votes
1 answer
asked Apr 17, 2023 in Linux/Unix by backtothefuture (551k points) | 39 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users