Create a Private Encrypted Folder On Ubuntu With eCryptfs

eCryptfs is a encryption application for Linux that you can use to encrypt your files/folders and prevent others from viewing it. eCryptfs does not require its own partition. You can easily create a dynamic encrypted private directory on your Home folder that will shrink or grow in size according to the files you add to it. Whatever files you place in the private directory will be encrypted and safe from the public eyes.

First, install the eCryptfs package:

sudo apt-get install ecryptfs-utils

Create your own secret folder.

mkdir /secret

Mount the ecryptfs to the secret folder

sudo mount -t ecryptfs ~/secret ~/secret

It will then prompt you to answer a few questions:

  1. Selecting your key type for newly created files
ecryptfs-key type

Press 1 to select “passphrase”. You will be asked to enter and verify your passphrase.

  1. Selecting your encryption cipher
ecryptfs-cipher

The default option is shown in the [ ]. If you are not sure of what to select, simply press Enter to select the default.

  1. Select “key byte”
ecryptfs-keybyte
  1. Enable plaintext passthrough

If you want to use unecrypted file inside your secret folder, then select Y. If not, type N.

Now, open your Nautilus (Places->Home Folder). You should see a “secret” drive mounted in the filesystem.

Testing out your secret folder encryption

First add some files to the secret folder. Then unmount it with the following command:

sudo umount ~/secret

Access the “secret” folder again and open any of the files that you have just added. You should not be able to open and view the file content. That’s good. All your files are now encrypted.

Creating a launcher

Having a launcher on your desktop allows you to mount the secret folder easily.

On your desktop, right click the mouse and select “Create Launcher”. Enter the following:

  • Type: Application in Terminal
  • Name: eCryptfs (or whatever name you want)
  • Command: sudo mount -t ecryptfs /home/USER/secret /home/USER/secret key=passphrase,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=n  (Replace the USER with your own username)

The next time you want to mount your secret folder, simply click on this launcher. It will pop up a terminal and ask you for your passphrase. Once that is verified, the secret folder will be mounted in the Home folder.

Damien
Damien

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox