Why share a set of headphones between MacOS and Fedora (or another Linux)?
Well, the answer to the ‘why?’ question is quite simple: because I dual boot between MacOS and Fedora on my Mac Mini. This means in order to use the same pair of headphones on MacOS and Fedora, I need them to use the same key, so the headphones think they are always connected to the same machine.
There are a couple of loose posts on the internet, especially on Ask Ubuntu about this topic already. I’m just combining those posts into a single blog for my own reference and potentially preventing people from having to dig up information from multiple places.
Simply said, Bluetooth pairing works by exchanging a secret key between two devices. Your operating systems (well, Linux anyway, but I assume MacOS does the same thing) associated a key with both the Bluetooth address on the local machine as well as the Bluetooth address of the remote device. Devices do the same thing.
This means that there can only be a single key for each point to point connection in the local Bluetooth “database”. And if you pair a set of headphones with MacOS and then with Linux, the key from the pairing with Linux will overwrite the key from the pairing with MacOS.
In other words, we have to make sure the pairing with both MacOS and Linux use the same key.
In order to share the Bluetooth key betwen MacOS and Fedora (or another Linux distro), we follow these steps:
- Pair on Linux
- Reboot into MacOS
- Pair on MacOS
- Extract the Bluetooth key from MacOS
- Reboot into Linux
- Swap out the old - now obsolete - key for the one from MacOS
Steps 1, 2 and 3
I’m not going to describe these in detail, as I’m assuming you know how this works :)
Step 4: extracting the Bluetooth key from MacOS
This is the crucial bit. On MacOS, open the Keychain app, and search for “bluetooth”. As you just paired the headphones, you are looking for the most recent entry called “MobileBluetooth”.
Double click it. It will show you the Bluetooth address in the
Account field. Make
a note of both what is in the
Account field and what is in the
Show password field.
You might have to provide your password once or twice along the way.
What is the the
Show password field will look something like this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>LinkKey</key> <string>00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00</string> <key>LinkKeyType</key> <string>UnAuthenticated</string> <key>LocalAddress</key> <string>11:11:11:11:11:11</string> </dict> </plist>
The bit aboce that reads
00-00-00-00-[...] is your Bluetooth key. The bit that reads
11:11:11:[...] is the Bluetooth address of your Bluetooth controller (i.e. the
Bluetooth address of your computer.
Step 5 and 6: reboot into Linux and swap out the key
Ok, now switch off your headphones for now, and make your sure you keep the note somewhere you can access from Linux and reboot.
Once rebooted into Linux, as root, go into
Obviously swap out the
11:11:11:[...] string for the Bluetooth address of your
In that directory, you’ll find another directory that is named after the Bluetooth
address of your headphones. This is what was in the
Account field on MacOS. I’ll use
22:22:22:[...] in this example. Enter that directory. You are now in
/var/lib/bluetooth/11:11:11:11:11:11/22:22:22:22:22:22. In that directory, there is
a file called
info file. It’ll look something like this:
[General] Name=Your Awesome HEadphone Class=0x240404 AddressType=public SupportedTechnologies=BR/EDR;LE; Trusted=true Blocked=false Services=[very long string here, shortened for readability] [DeviceID] Source=2 Vendor=1999 Product=3000 Version=1999 [LinkKey] Key=this_is_the_old_key Type=4 PINLength=0
Remove the dashes from the
00-00-00-[...] string and paste it in the
above, where it says
Save the file and run
systemctl restart bluetooth. Power on your headphones. Listen to
Hope this works as well for you as it did for me!!