I have tried the method described in the previous answer (i.e. following the tutorial in http://console.systems/2014/09/how-to-pair-low-energy-le-bluetooth.html) to set up a Surface Keyboard to work seamlessly on a Surface Book 2 with a dual-boot configuration with Windows 10 and Ubuntu 18.04m LTS. I did not work.
First, to get the most of your Surface on Ubuntu 18.04 you need to install the Jakeday kernel (https://github.com/jakeday/linux-surface). Secondly, to use the Microsoft Surface Keyboard (bluetooth) you need to get the last version of bluez (https://medium.com/@overcode/fixing-bluetooth-in-ubuntu-pop-os-18-04-d4b8dbf7ddd6).
The idea is to reverse the order of pairing, disable authentication in Ubuntu and then copy the keys to the Windows 10 registry:
Pair your Surface Keyboard in Windows 10. This will create the registry entries for the device.
Reboot in Ubuntu.
- Pair the keyboard in Ubuntu and get the keyboard Bluetooth address from
Settings>Bluetooth
, click on the connected Surface Keyboard
to copy the Address
(in my system it’s at CE:2E:25:B9:D1:0C
, keep this in mind!).
- Open a Terminal console and enter root:
sudo -i
.
- Edit the
info
Bluetooth configuration file to remove authentication. Go to the keyboard configuration directory: cd /var/lib
. Get the Bluetooth MAC address by listing the content of this directory ls
, then cd
into the keyboard's configuration folder. In my system its cd /var/lib/bluetooth/B8:31:B5:9A:5D:15/CE:2E:25:B9:D1:0C
, with the last bit being the keyboard Bluetooth address from step 3). Use your favorite editor to open the info
file on this directory to change the [LocalSignatureKey]
Authenticated
field to false
and the [LongTermKey]
Authenticated
field to 0
. This is how the info
file looks on my machine:
[General]
Name=Surface Keyboard
Appearance=0x03c1
AddressType=static
SupportedTechnologies=LE;
Trusted=true
Blocked=false
Services=00001800-0000-1000-8000-00805f9b34fb;00001801-0000-1000-8000-00805f9b34fb;0000180a-0000-1000-8000-00805f9b34fb;0000180f-0000-1000-8000-00805f9b34fb;00001812-0000-1000-8000-00805f9b34fb;[ConnectionParameters]
MinInterval=12
MaxInterval=12
Latency=20
Timeout=200
[DeviceID]
Source=2
Vendor=1118
Product=2327
Version=304
[IdentityResolvingKey]
Key=BAC8FF051F3EB6014D0B66678C725435
[LocalSignatureKey]
Key=C7E1BDA700A3213E12463D801F4B4496
Counter=0
Authenticated=false
[LongTermKey]
Key=721CEF56A21CFD5CB0BEF8F565F7F5A6
Authenticated=0
EncSize=16
EDiv=44718
Rand=14981484917123435222
- Turn off your Surface Keyboard (extract the batteries) and reboot Ubuntu.
- In Settings>Bluetooth>Surface Keyboard turn on the connection and re-insert the batteries. Your keyboard should connect and work properly. Reboot again (without extracting the batteries) to check that the keyboard is working properly.
- Save/Print the
info
file to access the keys to update the Windows 10 registry entries for the keyboard. In my case I have saved the file to a disk which is mounted on both Windows 10 and Ubuntu (to be able to copy/type data into the Windows 10 registry).
- Turn off your Surface Keyboard (extract the batteries) and reboot into Windows 10. Use
PSTools's psexec
to edit the registry. First, download PSTools
from http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx . Extract the zip file and open a terminal console with administrator privileges, change directory to the extracted files and run psexec -s -i regedit.exe
, this allows access to the privileged registry entries where the pairing keys are stored.
- Copy the keys from the
info
file to the Windows registry entries for the Surface Keyboard. First, you need to rename the two entries for the keyboard. Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters
. Rename the entries in under Devices
and Keys
which correspond to the Surface Keyboard. Each time you pair the keyboard, the address changes slightly to differentiate from prior pairings. In my case the initial Windows 10 pairing was on ce2e25b810c
while the subsequent Ubuntu pairing was on CE:2E:25:B9:D1:0C
(almost same address, excluding the :
and with letters in lower case, but notice the increase in b8
to B9
). Right-click on the registry names which correspond to the original Windows 10 pairing address to rename to the Ubuntu address .
After renaming the registry entries it looked like this on my system:
- Copy the keys from the
info
file to the Keys/{MAC Address}/{Bluetooth Address}
registry entry (\Keys\b831b59a5d15\ce2e25b9d10c
in my example). First, Modify
the Address
field by right-clicking on it and updating the Bluetooth address to the one used to pair in Ubuntu (in HEX from 'ce2e25b810c' in the original Windows 10 pairing to 'ce2e25b910c' in Ubuntu in my example).
Similarly, Modify
each of the following registry fields copying/typing the data from the Ubuntu info
file to the corresponding Windows 10 registry field:
IdentityResolvingKey
Key
value goes into the IRK
registry field. When modifying, erase the HEX entries and type the Key
from the info
file saved on step 8) in HEXADECIMAL format.
LocalSignatureKey
Key
value goes into CSRK
LongTermKey
Key
goes into LTK
Rand
goes into ERand
: enter the data from the info
file in DECIMAL format
EDiv
goes into EDiv
: enter the data in DECIMAL format.
12.Copy the Interval, Latency and Timeout values from the info
file to the Device
registry entry (all in DECIMAL format):
MaxInterval
goes into LERemoteConnParamsIntervalMax
MinInterval
goes into LERemoteConnParamsIntervalMin
Latency
goes into LERemoteConnParamsLatency
Timeout
goes into LERemoteConnParamsLSTO
- Reboot Windows and re-insert the batteries into the Surface Keyboard, which should connect to the Windows Bluetooth service. You should be able to boot seamlessly from Windows 10 to Ubuntu 18.04 and vice versa without having to re-pair your keyboard.