A command-line tool for mounting encrypted filesystems using passwords stored in KeePass. Built with Typer, Pydantic, and Python 3.10+.
This is a utility package that simplifies mounting encrypted filesystems by automating password retrieval from KeePass databases. It demonstrates:
- Modern Python packaging with
pyproject.toml - CLI development with Typer
- Type hints and static type checking with mypy
- Code linting with ruff
- Testing with pytest
- Dependency management with uv
Supports multiple encryption types including gocryptfs and cryfs with automatic detection.
- Identifies if already mounted by checking whether the decrypted path is a mount point
- Python 3.10 or higher
- uv package manager
- A KeePass database file (
.kdbx)
Clone the repository and install with uv:
git clone https://github.com/AlexAndrewsAI/mount-encrypted-filesystem.git
cd mount-encrypted-filesystem
uv sync- Example keepass database:
tests/enc.kdbx, password123 - Example gocryptfs vault:
tests/gocryptfs, passwordg1 - Example cryfs vault:
tests/cryfs, passwordc1
mount-encfs tests/filesystems/gocryptfs tests/filesystems/mnt \
--database tests/enc.kdbxYou'll be prompted for your KeePass password.
--enctype, -e: Specify encryption type (gocryptfsorcryfs). Auto-detected if omitted.--title, -t: Match a specific title in KeePass entries (defaults to encryption type).
# Auto-detect encryption type, prompt for password
mount-encfs tests/filesystems/gocryptfs tests/filesystems/mnt --database tests/enc.kdbx
# Specify encryption type and password
mount-encfs tests/filesystems/gocryptfs tests/filesystems/mnt \
--database tests/enc.kdbx \
--enctype gocryptfs
# Match specific KeePass entry by title
mount-encfs tests/filesystems/gocryptfs tests/filesystems/mnt \
--database tests/enc.kdbx \
--title "Work Vault"Use a YAML configuration file to mount multiple vaults with a single command:
mount-encfs batch tests/batch.ymlExample batch.yml:
database_path: tests/enc.kdbx
vaults:
- vault_enc: tests/filesystems/gocryptfs
vault_dec: tests/filesystems/gocryptfs_dec
title: custom
- vault_enc: tests/filesystems/cryfs
vault_dec: tests/filesystems/cryfs_decEach vault entry supports the same options as the single-mount command: vault_enc, vault_dec, enctype, and title.
mount-encfs --helpuv syncThis installs all dependencies and development tools (pytest, ruff, mypy).
# Run all tests
uv run pytest
# Run with verbose output
uv run pytest -v
# Show print statements during tests
uv run pytest -s# Lint code
uv run ruff check mount_encrypted_filesystem tests
# Fix linting issues automatically
uv run ruff format mount_encrypted_filesystem tests
# Type check
uv run mypy mount_encrypted_filesystemmount-encrypted-filesystem/
├── .gitignore
├── LICENSE
├── pyproject.toml
├── README.md
├── uv.lock
├── mount_encrypted_filesystem/
│ ├── __init__.py
│ ├── cli.py
│ ├── config.py
│ └── mount.py
└── tests/
├── __init__.py
├── batch.yml
├── enc.kdbx
├── test_mount.py
└── filesystems/
├── cryfs/
├── cryfs_dec/
└── gocryptfs/
- KeePass Integration: Securely retrieve passwords from KeePass databases
- Automatic Encryption Detection: Detect gocryptfs or cryfs automatically
- CLI Interface: Simple, intuitive command-line interface with Typer
- Type Safety: Full type annotations for IDE support and mypy compatibility
- Password Prompting: Securely prompt for passwords if not provided
- Flexible Matching: Match KeePass entries by title or encryption type
- typer — CLI framework
- pydantic — Data validation
- keepass-wrapper — KeePass database interaction
- mypy — Static type checking
- ruff — Code linting
- ✅ Type hints: Full type annotations throughout
- ✅ Docstrings: Clear module and function documentation
- ✅ CLI design: User-friendly argument parsing with Typer
- ✅ Security: Secure password handling with
getpass - ✅ Code quality: Automated linting with ruff
- ✅ Type checking: mypy validation
- ✅ Project structure: Clean package layout
- ✅ Python versions: Supports Python 3.10+
MIT
Contributions are welcome! Please feel free to submit pull requests or open issues.
AlexAndrewsAI alex.andrews.ai@protonmail.com