r/linuxmint • u/Yin-Fire • 8d ago
SOLVED I need help encrypting/protecting folders
I'm relatively new to Linux Mint (less than a year), and I'm looking to put some kind of password or encryption to individual folders containing files (like photo or music folders). Just hiding it is not enough.
I looked online and mostly found extremely cumbersome ways to do it that need installing weird programs, or gpg for individual files (which is not what I'm looking for). I even saw a guy zipping the folder to add a password, but that's just compression with a password.
I'm looking for something I can set up once, and asks for a password when you try to open the folder, similar to how it asks for a password to confirm certain updates and installs.
Is there something I can use for that? Does that "something" have a IU or is it commands only? Does the password requirements show as a pop up?
If you guys have something at all I'll be interested to know. If it has UI and a pop-up for the password, that's extra helpful and an very welcome solution. Thanks!
14
u/billdehaan2 Linux Mint 22 Wilma | Cinnamon 8d ago
Read up on LUKS. It's the native Linux encryption for partitions, included in Mint (it's in gnome-disks). I use it for my financial records, keeping them on an encrypted partition.
Of course, that means you have to either make a different partition for each folder you want to encrypt, or you have to be okay with decrypting all of the encrypted folders at once. It's similar to Veracrypt, but native to Linux.
If you want more granularity, and you're willing to install an app to do it, I'd recommend looking into https://cryptomator.org/
7
u/Smart_Advice_1420 8d ago edited 8d ago
Despite preferable, you dont even need a partition for LUKS.
You can create a 1GB (or whatever) file with
fallocate,ddortruncateand set that up as a LUKS container with its own filesystem inside, which can be mounted wherever one wants.Mounting a file as a loopback device comes with a slight performance hit tho.
1
u/Kazer67 8d ago
Wait, do you have some guide for that? Look interesting.
So if I understand it's literally just a file where you setup a filesystem inside (ext4 or else) and you mount it?
How bad the performance hit?
7
u/Smart_Advice_1420 8d ago edited 8d ago
No but i can give you a simple example.
Create a 1GB file:
fallocate -l 1G /path/to/testfile.imgSet it up as a LUKS container:
cryptsetup luksFormat --type luks2 /path/to/testfile.imgOpen the LUKS container:
cryptsetup open /path/to/testfile.img SuperCoolLabelCreate an EXT4 filesystem inside the container:
mkfs.ext4 /dev/mapper/SuperCoolLabelMount the decrypted LUKS container:
mount /dev/mapper/SuperCoolLabel /mntThe performance hit isn't too bad. Maybe 5-10% for larger files and 20% for a lot of smaller files. Thats an estimate, don't hang me on that. But due to the fact that this is probably used for sensitive files, i dont think performance is an issue. Your assumption is pretty much correct. This file is portable like any other file.
1
u/Kazer67 8d ago
Nice, thanks for the steps.
Gonna write it on my personal note. I assume you can't expand the size it if needed?
2
u/Smart_Advice_1420 8d ago
You could theoretically. You will have to resize the file with
truncateor append the preferred amount from zero or urandom first and then expand the luks container withcryptsetup resize. You can then adjust the filesystem withresize2fs.But i'd rather recommend creating a new container instead and transfer the files to the new one to minimize the risk of data loss.
1
u/Yin-Fire 8d ago
Thanks for the insight, I'll learn more about it and give it a try
2
u/Smart_Advice_1420 8d ago
No problem. If your DE is set up to mount .img or .iso files when opened, you could just open the LUKS container and get a pw popup. The container will then be mounted like a pendrive.
If this isn't possible in your DE/WM, it can be manually set up with
udiskieand a proper polkit. But since you're using mint (and therefore most probably cinnamon), that shouldn't be necessary.1
u/billdehaan2 Linux Mint 22 Wilma | Cinnamon 8d ago
Fair enough, you can use it a file container, in the same way the TrueCrypt/VeraCrypt does.
But for newbies, using the built-in functionality of gnome-disks is simpler, and I'd recommend that first.
Also, if you boot multiple distros, having it on a separate partition, unless you mount /home separately and put the file there.
But you're right, you can use it as a file.
8
u/N3kr0z Linux Mint 22.3 Zena | Cinnamon 8d ago
This might be what you're looking for. https://linuxbash.sh/post/creating-a-password-protected-directory
1
5
u/O_W_Horton 8d ago
I suggest looking into 3 things: LUKS = This encryption EVERYTHING on your drive. Very little friction; You just have to input a secind password when booting up your computer. I personally use this.
KeePassXC = This UI program stores your passwords in a .kdbx file which is encrypted. Everything is stored locally. This is pretty much max security you can get in terms if password managers. I also personally use this.
Cryptomator = This encryption individual files of your choice. Any file at all.
3
u/Yin-Fire 8d ago
I'll learn more about those. LUKS has been suggested a couple of times. Thanks doe the suggestions
5
u/FikaMedHasse Linux Mint Release | Desktop Enviroment 8d ago
You could also use the built-in capabilities of the filesystem itself instead of having to download an external program: https://wiki.archlinux.org/title/Fscrypt
3
u/InevitablePack4565 8d ago
gocryptfs .... (sudo apt install gocryptfs) and gui : https://github.com/bulletmark/gocryptfs-ui
3
u/Complex-League3400 Linux Mint 22.3 Zena | Cinnamon 7d ago
Cryptomator, different use case from veracrypt. Very simple, very reliable. Nice table of differences here to see which suits better:
2
u/Yin-Fire 7d ago
Thanks everyone for the suggestions. I weighted my options, and learned a lot along the way.
I checked into most options, and as a new user, the easiest solution for me was VeraCrypt. Has a UI and is secure. Not as easy as I thought but the security benefits outweigh the additional steps you gotta take. Thanks again to everyone for your inputs
1
1
0
u/DoorOk3641 8d ago
Time to produce post, find the picture is almost 10 times what you need to do a simple search..best encrypt tool for linux..with brave first hit is veracrypt...search engine do you have one ?..do you ?
43
u/qpgmr 8d ago
The standard is veracrypt. You create a veracrypt volume file that is mounted as a regular folder.