Skip to main content

btkey-sync

PyPI version Python 3.10+ License: MIT

Synchronize Bluetooth pairing and cryptographic bonding keys (BLE and Classic BR/EDR) between operating systems in dual-boot setups (Windows & Linux) or across partitions and physical machines — without having to re-pair devices on every reboot.


Why This Exists

Bluetooth peripherals (keyboards, mice, headsets) generate cryptographic keys during pairing. Dual-booting causes devices to fail on OS switches because each OS stores independent keys:

Feature Windows Linux (BlueZ)
Storage Location HKLM\SYSTEM\...\BTHPORT\Parameters\Keys /var/lib/bluetooth/<adapter>/<device>/info
Required Privileges SYSTEM account (automated via scheduled task) root (sudo)
Numeric Formats Hexadecimal (dword, qword, hex) Decimal (EDiv, Rand)
Daemon Reload Immediate Requires systemctl restart bluetooth

btkey-sync automates extracting, converting, importing, and validating keys across systems.


Installation

From PyPI

pip install btkey-sync

(Or via pipx install btkey-sync for isolated CLI environments)

From Source

git clone https://github.com/netssv/btkey_sync.git
cd btkey_sync
pip install .

Optional Dependencies (Linux Offline Windows Reading)

To clone directly from a mounted Windows partition on Linux without booting Windows:

sudo apt install chntpw bluetooth   # Debian/Ubuntu/Mint
sudo dnf install chntpw bluez       # Fedora/RHEL
sudo pacman -S chntpw bluez-utils   # Arch Linux

Usage

1. Interactive TUI Menu (Recommended)

Run the command with elevated privileges:

Linux:

sudo btkey-sync

(If run as normal user, btkey-sync will offer to re-launch with sudo automatically).

Windows (PowerShell / Command Prompt as Administrator):

btkey-sync

The menu provides:

  • [1] Clone Device: Directly sync BLE, Classic, or Dual-Mode devices from a mounted Windows partition (/mnt/windows) or local installation.
  • [2] Export Key to File: Export device pairing data to .reg + .json sidecar files.
  • [3] Import Key from File: Load a .reg file and inject keys into the host Bluetooth stack.
  • [4] Force Push Sync: Clear daemon caches, restart BlueZ, set trust, and reconnect.
  • [5] Remove Device: Delete bonding for a device cleanly with automatic backup.
  • [6] Show Keys: Inspect all locally stored bonding keys and parameters.
  • [7] Device Help & Advice: Guidance on BLE vs. Classic single-slot devices.

2. Direct CLI Flags

# Non-interactive import of an exported .reg file
sudo btkey-sync --import exports/aabbccddeeff__windows__20260829.reg

# Force reload BlueZ stack, trust, and reconnect to a specific MAC
sudo btkey-sync --push-sync AA:BB:CC:DD:EE:FF

Dual-Boot Migration Workflows

Method A: Offline Cloning on Linux (Fastest)

  1. Pair device in Windows.
  2. Boot into Linux and mount your Windows partition (e.g. at /mnt/windows).
  3. Run sudo btkey-sync and select Option 1 (Clone Device).
  4. Select the detected Windows partition. btkey-sync reads the keys offline and sets up BlueZ automatically.

Method B: Export / Import via .reg File

  1. Pair device on Source OS (e.g. Windows).
  2. Run btkey-sync → Option 2 (Export) to generate a .reg file in exports/.
  3. Copy the .reg file to the Destination OS (via USB drive or shared partition).
  4. On destination, run sudo btkey-sync → Option 3 (Import).

Documentation Wiki

Detailed guides are available in the docs/ directory:


Testing

python3 tests/test_parsing.py

License

MIT License. See LICENSE for details.

Metadata

Release files for btkey-sync 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for btkey-sync 0.2.0
File Size Uploaded
btkey_sync-0.2.0.tar.gz 44.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for btkey-sync 0.2.0
File Interpreter ABI Platform
btkey_sync-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 99.4 kB

Release files / btkey_sync-0.2.0.tar.gz

Download URL btkey_sync-0.2.0.tar.gz
Size 44.6 kB
Tags Source
SHA-256 checksum
How to use checksums
042d1176c44d2b2dbf340fa40e5591d42b3acb5c1f36bbd348772c585c3160fc
BLAKE2b-256 checksum
How to use checksums
b8b8e44b841353382bb59b10e5de09a58380c0ca34261be345912a8ee149d3ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / btkey_sync-0.2.0-py3-none-any.whl

Download URL btkey_sync-0.2.0-py3-none-any.whl
Size 54.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41aecf70515a0174ce47d5e3e330adbfb17ee4be528143054bb4391f7d3a2562
BLAKE2b-256 checksum
How to use checksums
f271d5699747e78d5b425dbcec72104a104e2f8ca9a59b4ddb7fe68f1bd251b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page