Automount LUKS Filesystems

larry1chan@qq.com ac225a3bb2 add new util пре 10 месеци
.gitignore 314db4abbf first commit пре 10 месеци
automount_luks.py 314db4abbf first commit пре 10 месеци
crypt_tools.py 314db4abbf first commit пре 10 месеци
examine_files.py ac225a3bb2 add new util пре 10 месеци
luks_mount.conf ac225a3bb2 add new util пре 10 месеци
master_passkey 314db4abbf first commit пре 10 месеци
private_key.pem 314db4abbf first commit пре 10 месеци
public_key.pem 314db4abbf first commit пре 10 месеци
random_pass.py 314db4abbf first commit пре 10 месеци
readme.md 314db4abbf first commit пре 10 месеци

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.