Automount LUKS Filesystems

larry1chan@qq.com 671d9aee0f new mounts after 4T damaged disk 4 ngày trước cách đây
.gitignore 314db4abbf first commit 10 tháng trước cách đây
automount_luks.py 671d9aee0f new mounts after 4T damaged disk 4 ngày trước cách đây
automount_luks.sh 671d9aee0f new mounts after 4T damaged disk 4 ngày trước cách đây
crypt_tools.py 671d9aee0f new mounts after 4T damaged disk 4 ngày trước cách đây
examine_files.py ac225a3bb2 add new util 10 tháng trước cách đây
luks_mount.conf 671d9aee0f new mounts after 4T damaged disk 4 ngày trước cách đây
master_passkey 314db4abbf first commit 10 tháng trước cách đây
private_key.pem 314db4abbf first commit 10 tháng trước cách đây
public_key.pem 314db4abbf first commit 10 tháng trước cách đây
random_pass.py 314db4abbf first commit 10 tháng trước cách đây
readme.md 314db4abbf first commit 10 tháng trước cách đây

readme.md

Automount LUKS Filesystems

Overview

This script automates the process of mounting and unmounting LUKS-encrypted filesystems. It uses a configuration file to store the device UUIDs, mount points, and encrypted passphrases.

Requirements

  • Python 3.x
  • argparse library
  • cryptography library
  • subprocess library

Configuration File

The configuration file is expected to be in the following format:

uuid  mount_point  encrypted_passphrase

For example:

f48bfd48-e478-4fd1-97b0-5bf66844b584  /media/yazoo/luks-f48bfd48-e478-4fd1-97b0-5bf66844b584  c6jvKUgjvNhImxO2OpndSHRMeO4N7+R2oN2i2eiqsXwSqMCD2juqSXRSUI8QrNOqR/SLRX5vkBZkwZ669Xv8nRXHpeWsSzr7t9qUjz48tIgTH/sfVDkxztyKre247M4hRAHUBevXTFRaa8H81w3x59Loix5/nlZ0EqYgyM/vSZzGv3hZIeIia2tWxE8b7Mbb/BwCj9fjxVgTD5v0TsfHQftf/BwWJcFqIleFDaD84hVfzAyOwNJhn56DanbUiwHnKwgr/HZ7/36UZ/rbB7zBaLt2hFaY3t6012bdkEzOe9/9b0UCXtoMeL9XmNQm5mWEtzOlcoUJUlpNkZSuaaJV+g==

Usage

The script can be run with the following options:

$ python automount_luks.py -h
usage: automount_luks.py [-h] [-m] [-c CLOSE] [-f CONFIG_FILE]

optional arguments:
  -h, --help            show this help message and exit
  -m, --mount           Mount the specified device
  -c CLOSE, --close CLOSE
                        Close the specified device
  -f CONFIG_FILE, --config CONFIG_FILE
                        Specify a configuration file

Key Generation

The script uses RSA keys to encrypt and decrypt the passphrases. The keys can be generated using the crypt_tools.py script:

$ python crypt_tools.py

This will generate a private key file (private_key.pem) and a public key file (public_key.pem).

Notes

  • The script assumes that the cryptsetup and mount commands are installed and available on the system.
  • The script uses the sudo command to run the umount and cryptsetup commands with elevated privileges.
  • The script does not handle errors well, and may require additional error handling and logging in a production environment.