It’s easy to share traditional keyboards between multiple computers using a USB KVM. Obviously, with a bluetooth keyboard, things aren’t so simple.
I wanted to share my Apple bluetooth keyboard between my Mac mini and my desktop computer (running Ubuntu, but this would work with Windows).
First step was to get a USB bluetooth dongle and plug that into the KVM. Any USB dongle should do. When the KVM is switched to the Mac, the bluetooth dongle takes preference over the built-in Mac bluetooth receiver.
This works to share the keyboard, but the keyboard had to be disconnected and re-paired each time the KVM was switched — this is particularly problematic if you need to repair the keyboard at, for example, the login screen. It also requires you to enter a PIN code each time.
Fortunately this can be easily solved by sharing the generated link key between the two computers:
- Pair the keyboard in Ubuntu, then in OSX.
- In OSX, look at the bluetooth properties for your keyboard device to get the address.vThen open the terminal and type
sudo defaults read /private/var/root/Library/Preferences/blued.plist
. You will see something like the following:{ LinkKeys = { "00-aa-bb-cc-dd-ee" = { "00-00-00-aa-aa-aa" = <81a83517 cc3c7afc fb8e99fc 5147fbf4>; }; }; }
Here, the first code is the address of the bluetooth dongle. The second is the address of the keyboard, and the final, longer code is the link key.
- Convert the link key into a format suitable for Linux (or Windows), by reversing the endianness; simply reverse the order of the key, taking each pair of hexadecimal numbers as one value. So, the above key would be f4fb4751 fc998efb fc7a3ccc 1735a881. Easy…
- Use this link key in Linux or Windows. On Ubuntu the link key is at /var/lib/bluetooth/00:AA:BB:CC:DD:EE/linkkeys — the code is the address of the bluetooth dongle. Edit that file and replace the link key corresponding to the address of the bluetooth keyboard to the converted key, above.
- That’s it — restart Ubuntu, and the keyboard will work seamlessly as it is switched by the KVM.
To change the link key in Windows, you need to edit the registry — I didn’t do this, but a search for “Windows bluetooth link key registry” should give the goods.
Provided the keyboard doesn’t become unpaired, the setup should last indefinitely.