2 minute read

Use the same bluetooth device on the same computer under different OSs

The problem

I tried to connect my bluetooth headphones to my personal computer, which is running both Pop_OS and Windows 10. I have a single bluetooth interface installed and while both OS allow for the pairing process, the moment one paired, the other OS would stop recognizing the headphones.

Why this is happening

The Bluetooth handshake process exchanges a key while pairing, which is introduced in this case by the OS, and both obviously start a new handshake from scratch on each pair. Since the hadware addresses are identical (MAC addresses, basically), my headphones would say “Hey! I know this PC, I’ll connect to it” only to find it had a different key.

The solution

I searched for a bit and found this stackoverflow post which solved all my problems. I strongly recommend the “Linux first approach”, which goes as follows:

For simplicity’s sake, let’s assume you are pairing a bluetooth headset, but any bluetooth device should work.

1) Pair the headset on windows

Make sure it works!

2) Pair the headset on linux

Reboot to linux and pair your headphones again from scratch. Make sure it works! Write down the MAC address of your headset for reference in step 4.

3) Become root

sudo su

4) Read the key

On your root terminal, head over to /var/lib/bluetooth/AA:AA:AA:AA:AA:AA/BB:BB:BB:BB:BB:BB.

cd /var/lib/bluetooth/AA:AA:AA:AA:AA:AA/BB:BB:BB:BB:BB:BB

Where:

  • AA:AA:AA:AA:AA:AA is your computer’s bluetooth interface (you’ll most likely only have one)
  • BB:BB:BB:BB:BB:BB is your headphones’ MAC address from step 2. If you didn’t find it there, you can always
sudo bluetoothctl info

Once there, open file info and write down somewhere you can access from windowsthe LinkKey Key

root@rhopop:/var/lib/bluetooth/00:11:22:33:44:55/01:02:03:04:05:06# ls -lisa
total 12
10229895 4 drwx------ 2 root root 4096 ene  6 09:57 .
 9833231 4 drwx------ 4 root root 4096 ene  6 09:09 ..
10229896 0 -rw------- 1 root root    0 ene  6 09:09 attributes
10229898 4 -rw------- 1 root root  569 ene  6 09:57 info
root@rhopop:/var/lib/bluetooth/00:11:22:33:44:55/01:02:03:04:05:06# cat info
[General]
# Irrelevant

[DeviceID]
# Irrelevant

[LinkKey]
Key=0123456789012345678901  <----- This key!
Type=4
PINLength=0

5) Overwrite the key windows used for this one

Turn off your device, reboot and download psexec to your windows desktop or folder of your choice

Open an administrator terminal or powershell (Right click on the windows icon in the lower left corner of your screen > “Open powershell (Admin)”) and type

psexec -s -i regedit.exe

Navigate to

HKEY_LOCAL_MACHINE\SYSTEM\\ControlSet001\Services\BTHPORT\Parameters\Keys\AA:AA:AA:AA:AA:AA

Where, again, AA:AA:AA:AA:AA:AA is your interface’s address.

You will see inside a file with your headset’s address (BB:BB:BB:BB:BB:BB). Righ click it and “Modify binary data”.

Remove the content and type the key from step 4.

6) Close the registry and turn on your headset!

It should connect to either OS without needing to pair it every time!

Thanks GoJian!