I have an iMac with both macOS and Ubuntu on it. I want to be able to use my Bluetooth mouse and keyboard with both operating systems without re-pairing every time I switch OS.
Has anyone had this problem and figured out a solution?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityI have an iMac with both macOS and Ubuntu on it. I want to be able to use my Bluetooth mouse and keyboard with both operating systems without re-pairing every time I switch OS.
Has anyone had this problem and figured out a solution?
The answers to this question give you the general idea, though a bit vague on the macOS side, so I'll spell out the procedure I used.
OS versions as follows. The file names and locations appear to be subject to change according to versions, so this is what worked for me.
I am assuming that you have a filesystem (USB key or whatever) that is at least read-write in MacOS and readable in Ubuntu.
The general idea is that when you pair a device to an OS, a unique link key is generated, which is necessary for authentication next time the pairing is active. You can transfer these link keys from MacOS pairings to Ubuntu pairings such that the pairings work in both OSes.
sudo defaults read com.apple.bluetoothd.plist LinkKeys
. This will give you output something like:{ "a0-99-9b-16-43-d2" = { "00-1f-20-47-e5-22" = <4d6b002f 37584c09 ee219365 b78ba03e>; "04-0c-ce-3d-15-4d" = <fe998c62 4bb29a7c 40b2e670 10db71ed>; }; }
Here a0-99-9b-16-43-d2
is the MAC address of the bluetooth adapter on my system.
Following that are the MAC addresses of devices that I have paired (00-1f-20-47-e5-22
and 04-0c-ce-3d-15-4d
and the link keys associated with those pairings (4d6b002f 37584c09 ee219365 b78ba03e
and fe998c62 4bb29a7c 40b2e670 10db71ed
respectively).
sudo defaults read com.apple.bluetoothd.plist LinkKeys > /Volumes/4T/linkkeys.txt
sudo service bluetooth stop
/var/lib/bluetooth
. You should see a subdirectory entry for the bluetooth adapter MAC address, formatted like A0:99:9B:16:43:D2
. Inside that you should see subdirectories for each device MAC address, like 00:1F:20:47:E5:22
and 04:0C:CE:3D:15:4D
. Inside those directories you will find files named info
. Edit these files with your favourite editor:sudo gedit /var/lib/bluetooth/A0:99:9B:16:43:D2/00:1F:20:47:E5:22/info sudo gedit /var/lib/bluetooth/A0:99:9B:16:43:D2/04:0C:CE:3D:15:4D/info
Key
entry. This key needs to be made the same as what you found in MacOS, but with some important formatting differences:
You can achieve this as follows:
$ echo 4d6b002f 37584c09 ee219365 b78ba03e | sed 's/ //g;s/../\U&\n/g' | tac | tr -d '\n' ; echo 3EA08BB7659321EE094C58372F006B4D $ echo fe998c62 4bb29a7c 40b2e670 10db71ed | sed 's/ //g;s/../\U&\n/g' | tac | tr -d '\n' ; echo ED71DB1070E6B2407C9AB24B628C99FE $
Edit these reformatted keys into the Key entry of the appropriate info files. Most likely sudo
will be required.
sudo service bluetooth start
Update: The pairings seem to have persisted through upgrades on both MacOS and Ubuntu. I'm now running 10.13.6 and 18.04 respectively and have not yet had to redo this procedure.