How to use Apple bluetooth keyboard with multiple computers via a KVM

Standard

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:

  1. Pair the keyboard in Ubuntu, then in OSX.
  2. 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.

  3. 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…
  4. 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.
  5. That’s it — restart Ubuntu, and the keyboard will work seamlessly as it is switched by the KVM.
  6. 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.

52 thoughts on “How to use Apple bluetooth keyboard with multiple computers via a KVM

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>