Tomb is a simple script that allows you to encrypt files in Linux. Unlike full-disk encryption, Tomb allows you to encrypt only the files and folders you want. Here we show you how to install and use Tomb on Ubuntu, as well as how to encrypt files in Linux using Tomb.
Why Use Tomb to Encrypt Files in Linux
One of Tomb's biggest advantages is that it requires no additional software to install and use. This means it can be used on an existing system without an internet connection. This can be useful in situations where you need to quickly encrypt a file on a live system like Kali Linux.
Tomb relies heavily on the software and utilities that come by default in Most popular Linux distributionsFor example, Tomb uses both GNU Privacy Guard to handle its encryption and dd to wipe and format its virtual partitions.
This means that Tomb will always use the latest coding and programming techniques when maintaining its files. This approach also allows the program to focus on integrating itself into your system rather than creating its own environment. As a result, you can easily adapt Tomb and its files to work with any custom script. shell You created it on your device.
Finally, the Tomb file is also highly flexible. It allows you to modify its properties seamlessly without affecting its contents. For this reason, you can also use it as a simple encrypted backup.
Installing Tomb on Ubuntu
- Make sure that all Tomb dependencies are present on your system. You can double-check this by running the following command:
sudo apt install zsh file gnupg cryptsetup pinentry-curses wget make steghide mlocate
2. Download A copy of Tomb From the developer's website:
wget https://files.dyne.org/tomb/releases/Tomb-2.9.tar.gz
3. Extract the Tomb utility to your home directory. You can do this by running the following command:
tar xvzf ./Tomb-2.9.tar.gz
4. Go to Tomb Guide Install it on your system using make:
cd Tomb-2.9 sudo make install
This command will automatically copy Tomb to “/usr/local/bin” and set the correct permissions to work. You can also check if you have installed the program correctly by running man tomb
Create your first Tomb to encrypt files
With the software installed, you can start using Tomb to encrypt your files. Tomb works by allocating a specific space to be encrypted in advance. You can copy your files to this space later, and Tomb will encrypt them on the fly.
To allocate space for the first Tomb, you need to use the dig subcommand. The following command creates a 100MB Tomb file named “first.tomb.”
tomb dig -s 100 first.tomb
Next, you need to create a key for your new Tomb file:
tomb forge -k first.tomb.key
It's important to note that running this command can be resource-intensive for your system. This is because the forge subcommand attempts to generate as much random data as possible for its keys. You can mitigate this problem by continuously moving your mouse cursor during this process.
Once you have your key, you can now associate it with your new Tomb file. To do this, you can run the lock subcommand:
tomb lock -k first.tomb.key first.tomb
Finally, you can open the newly closed Tomb by running the open subcommand:
tomb open -k first.tomb.key first.tomb
Running this command will prompt you for your Tomb password (if you don't remember yours, check out these password managers for Linux). It will then automatically mount your file as a separate partition on your system.
Create an image key to encrypt files
Aside from creating simple password keys, you can also use images to unlock your Tomb files. This can be useful if you want to share Tomb files with others without directly sharing your password.
To create an image key, you need to use the bury subcommand. For example, running the following command will merge the file “first.tomb.key” with file “image.jpg” My own.
tomb bury -k first.tomb.key image.jpg
Once done, you can now use your image to open the Tomb file. The following command opens the file: “first.tomb” Using my new image key.
tomb open -k image.jpg first.tomb
Close Tomb
Unlike a regular encrypted drive, a Tomb file doesn't act as a separate device in your system. Instead, it acts as an isolated partition within your file system.
One problem with this approach is that you need to use program-specific subcommands to cleanly unmount the Tomb. For example, running the following command will re-encrypt the contents of the Tomb and cleanly unmount it from your current session:
tomb close
Aside from that, you can also close any Tomb installed on your system. This is useful if you have an application that is misbehaving and won't quit.
However, it's important to note that forcing a dismount could corrupt data within the Tomb. Knowing this, you can perform a close dismount by running the slam subcommand:
tomb slam
Tomb expansion and indexing
It's also possible to increase the storage space for your Tomb files. This can be useful for users who want to store more data but don't want to encrypt a new partition for their data.
To do this, you need to use the resize subcommand. For example, running the following command will expand the size of my first.tomb file from 100MB to 1GB:
tomb resize -k first.tomb.key -s 1000 first.tomb
Search the Tomb
Finally, you can also create easily searchable indexes of currently open Tomb files. This is useful for users who want a quick way to manage multiple encrypted partitions.
In order to search your Tomb files, you first need to create an index for them. To do this, run the following command:
tomb index
Next, you can search all currently open Tomb files by running the sub-search command. For example, running the following will search for every file containing the word "a test":
tomb search test
Frequently Asked Questions
Q1. Can you use Tomb on a different Linux distribution?
answer. Tomb is a highly portable scripting program based on only a small set of Linux utilities. This means that the program will likely run on your machine as long as you have the correct dependencies. For example, both zsh and GNU Privacy Guard are programs that are often found in any distribution's repository.
Q2. Can you bind one key to multiple Tombs?
answer. Yes. Similar to Publish SSH key pair It is possible to use a single key to manage multiple Tomb files. To do this, you need to create your new file by running: tomb dig -s 100 test2.tomb.
Next, you need to link your new tomb file using the lock subcommand. For example, running the following will link my new test2.tomb to test.tomb.key Present: tomb lock test2.tomb -k test.tomb.key.
Q3. Is it possible to reduce the size of a Tomb file in Linux?
answer. No, the Tomb developers designed their encrypted filesystems to only grow in size. This is mostly due to the way both encryption and resizing work between cryptsetup and resize2fs.
The only way to "shrink" a Tomb file is to create a new, smaller Tomb file using the dig subcommand. You can then bind this new Tomb file to your existing key using the lock subcommand.