Let's say that I have a folder, within my Documents folder, that has files I want no one to access without a password.
Is there a way to lock down that folder so that it's password protected / encrypted?
In fact, is it possible to password-protect any individual folder?
Cryptkeeper
After installing, go to Applications –> System Tools –> Cryptkeeper.
Cryptkeeper will automatically attach itself to the top panel
To create an encrypted protected folder, click on Cryptkeeper applet and select ‘New encrypted folder’
Then type the folder name and where to save the folder and click ‘Forward’.
Type the password and click ‘Forward’.
The folder will be created and ready to be used.
To access all encrypted folder, click on Cryptkeeper applet on the panel and select each folder.
Type the password before it is mounted to be accessed.
Done
To delete a folder or change the password, right-click the folder in the panel-applet.
For More Help
eCryptfs
EncryptedPrivateDirectory Method.
Ubuntu Official Wiki
Search for and install ‘ecryptfs-utils’ in Ubuntu Software Center:
After installing, go to Applications –> Accessories –> Terminal and run the command below:
You’ll be prompted to type your login passphrase (password), and to create one for your private folder:
When you’re done creating your password, Log Out and Log back in:
Next, go to Places –> Home Folder:
And new folder should be created in your home directory called ‘Private’. This folder in encrypted and password-protected. Move all your personal stuff into this folder to secure them:
Users without access to the folder will be denied:
For More Help
You have 2 choices if you want to lock down a folder from other users
Encrypt or create a compressed password protect archive of the files. This method (Cryptkeeper) is perfect for this case when you need to be 100% sure no one will ever look at your files without knowing the password used there.
Use your computer folder / file permissions to deny access to your folder to other user.
The first involves making sure that the result cannot be opened by any user without knowing the password used.
The second will only change the file / folder privileges so that another user without rights cannot open it. The folder still exists, can be accessed by any user with
sudo
rights in your system or using a LiveCD and reading the partition. It is also simpler to implement and does not require that you type a password all the time you need to open / mount the encrypted folder / archive.An easy and fast way to do so is using
chmod
to change the privileges for a file or folder.Open a terminal and navigate to the place where your folder is, lets assume that the folder name is
foo
and that we are currently located where the folder is.will make
foo
only available for your eyes, its not encrypted (that is also possible) but only your user (and or a user with sudo privileges) can read or open that file / folder.You can also do it graphically by right clicking on a file or folder and changing its permissions manually. In the example below you as owner have all privileges and you deny any other group or user from accessing, reading or modifying that file / folder
For more information about file / folder permissions visit the Ubuntu
Understanding and Using File Permissions
wiki page.Another way, depending on your needs is to archive the folder as a password protected zip file.
This is similar to another question about password protecting files.
Vault
Last update: Aug 4, 2012
You can try Vault, recent project by an ubuntu-gr member (greek local community).
PPA:
It's a gui utility for encfs (package in repositories). I quote the package description:
You create a mountpoint/folder which you can then close or delete. If you close it, you need a password to open it.
CryFS
You can use CryFS:
It is used by default in KDE Vaults and is particularly interesting if you synchronize the encrypted content over Dropbox, Freefilesync, rsync or similar software, because it keeps its data in small encrypted blocks and changing a small file results in only a small amount of data to be re-uploaded.
Directory level encryption is a risky thing, prefer block device level encryption whenever possible.
I think Giles nailed several key points here, which I'll reproduce:
Also note that if you encrypt something inside your home and not the entire home itself, several common programs can lead to data leaks unless you are hair splittingly careful. E.g.:
.bash_history
, editor sessions and undo histories, etc.Some pointers on how to do this:
fscrypt
after a non-encrypted installation (the installer has an option to encrypt the home directory)eCryptfs manual setup
This answer described the Ubuntu helpers for it (e.g.
ecryptfs-setup-private
), but you can get more control (e.g. separate different mount directories) and understanding by mounting it yourself.eCryptfs is already part of the Linux kernel and already enabled by default on Ubuntu via
CONFIG_ECRYPT_FS=y
, so you can just basically mount it. Being part of the kernel is also generally a positive indicator of quality and stability.I have the following helpers:
GitHub upstream.
Usage is as follows.
First mount the encrypted directory:
This will now ask you for a passphrase:
Suppose we unwisely choose:
so it will now print:
87d04721f6b4fff1
is a type of hash derived from ourasdf
password. You can now hit enter, and it will say:which means that the mount was successful.
Now let's make some test encrypted files:
If we unmount it:
as expected the directory is empty:
The eCryptfs data itself is contained in the
~/.ecryptfs-dat
directory we passed to the mount command.No matter where we mount to, as long as we use that directory as the data directory, the contents of the unencrypted mount point will be the same.
Let's observe its contents:
This shows three encrypted files:
So we observe that:
We can now check if those files are actually encrypted:
which gives no matches, so they likely are encrypted.
The cool thing about how those encrypted files are stored, is that you can then easily backup the encrypted files anywhere by just copying them over to an unencrypted medium with
rsync
, and only out-of-date files will be copied. There is no need to even first enter your password in that case!The non-cool thing about it, is that an attacker who is trying to prove that you had a known piece of information might be able to prove that by comparing the file sizes and directory structure layout as mentioned by Giles.
Now let's mount again:
Once again, it asks for the password.
Suppose you enter the wrong password:
it will now print:
So we observe that the FNEK for
asdfqwer
is different than that of the correctasdf
password:c55c6f13e73332d3
.If we decide to mount anyways with
yes
, it then asks:and if we enter
yes
, it would, as promised add the FNEK to the/root/.ecryptfs/sig-cache.txt
. Let's say no for now. We can check what that file contains:it currently only contains the
asdf
FNEK:so we understand that it is just a whitelist of known good passwords.
Now let's see what we get with the wrong password:
and we see that the directory is empty as you might expect. It seems that each file in the data directory must contain some kind of password check data, and just doesn't get mounted.
If we umount and move back to the correct password
asdf
, it wil once again ask for FNEK confirmation which is a bit annoying.We can prevent that from happening every time as mentioned at How to automatically specify the Filename Encryption Key with ecryptfs? by adding:
to the mount command. TODO would knowing the FNEK help attackers crack the password?
Finally, when the ecryptfs directory mounted, we can see it under:
which contains a line of type:
Tested on Ubuntu 20.04, Linux kernel 5.4.
ecryptfs vs CryFS vs EncFS
These are all directory-level methods so it would be good to understand their tradeoffs, Some comparisons:
https://www.cryfs.org/comparison/
https://wiki.archlinux.org/index.php/EncFS#Comparison_to_eCryptFS
Full disk encryption at install time (except
/boot
)I can't find "the question" for this, so here goes a QEMU experiment based here with Ubuntu 20.04.1.
You click:
Then it asks you for a password on the next step:
Now, every time you boot, the very first thing you see, (TODO before or after the bootloader?), is a password prompt:
And after this, if you enter the correct password, it goes into a normal boot.
After logging in, from inside a shell we do:
and that gives:
so it appears that the second stage bootloader under
/boot
itself is not encrypted, but the root directory and swap are.As mentioned at: https://help.ubuntu.com/community/Full_Disk_Encryption_Howto_2019 this opens you to the risk that an attacker would be able to compromise your machine by tampering with the boot folder, without your knowledge, and use that to later extract your decryption keys if you continue to use the machine.
Full disk encryption at install time (including
/boot
)There doesn't seem to be an automated way of doing it as of 20.04, but hopefully it will get implemented sooner or later, some manual guides:
Kill switch turned on laptop encryption security
OK, we are now reaching a CIA/Silk Road level of opsec paranoia topic: how to quickly ensure that your data can't be decrypted if you are caught with the computer turned on and have a second to act.
First, suspend to RAM does not seem to be good enough, hibernation will be a wiser move:
Hibernation seems to save data in the swap partition, so as long as your swap is encrypted (Which it obviously should be in an encryption setting, otherwise your RAM will leak there), it should be safe.
Now, on a laptop, the best method is likely a lid closing action, e.g. this post mentions that:
on
/etc/systemd/logind.conf
should workAlternatively should setup a keyboard shortcut or a power button action. How to hibernate from CLI: How can I hibernate on Ubuntu 16.04? mentions:
You could also use gocryptfs. In my experience it is significantly faster than cryfs with big encrypted shares, but does not hide the structure (file sizes and number of files). depending on your threat model this may or may not be a problem.
To install
To initialize the basedir (once)
To mount basedir (the encrypred version) on mountdir (the unencrypted version)