Click here to Skip to main content
15,887,596 members
Articles / Configuration

Connect a Dell Bluetooth keyboard with both Windows 11 and Ubuntu 22

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
23 Jan 2024CPOL5 min read 1.8K   1
Dual-system Bluetooth keyboard setup: Seamless pairing with Windows 11 and Ubuntu 22
The article details the process of seamlessly configuring a Dell Bluetooth keyboard for dual-system use with Windows 11 and Ubuntu 22, covering pairing, registry key migration, and Bluetooth configuration adjustments for optimal performance.

A few months ago, I purchased a Dell Bluetooth keyboard for use with my desktop PC, which has both Windows 11 and Ubuntu 22 installed. This article will share my findings and the steps I have taken to get the keyboard to work seamlessly with both operating systems.

This is essentially what I have done:

  1. Pair the keyboard on Ubuntu 22 first, so as to create the necessary configuration files
  2. Reboot to Windows and pair it under Windows, so as to create the needed registry keys
  3. Reboot to Ubuntu and update various Bluetooth configuration files to reflect the latest values from the attempt to pair with Windows

Step (3) is needed because most Bluetooth devices will generate new pairing keys if you pair them with a new host, invalidating any previously paired connections. If your device can pair with a new host without invalidating existing connections, a simpler workaround would be to pair the device under Ubuntu as usual, purchase a separate Bluetooth dongle and configure Windows to use this Bluetooth dongle instead of the built-in Bluetooth device. This is trivial and will not be covered in this article.

To note, the default installation of Ubuntu 22 may have problems with Bluetooth keyboard on some hardware. If this is the case for you, please follow the instructions here to update to the latest Bluetooth kernel. The commands that I have used are summarized below:

wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.66.tar.xz
tar xvf bluez-5.66.tar.xz
cd bluez-5.66
sudo apt-get update
sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev python3-docutils
./configure --enable-library
make
sudo make install
reboot

It goes without saying that you need not attempt the above steps if your Bluetooth keyboard already works with the default Ubuntu installation.

To migrate the Bluetooth pairing keys from Windows to Ubuntu, I followed the instructions from this Github note, adjusted to suit my installation. For what it’s worth, you will not be able to view the registry branch which contains the Bluetooth pairing keys (HKLM\SYSTEM\ControlSet001\Services\BTHPORT\Parameters\Keys) using regedit due to Microsoft security policy. If you try to do so, you will simply see an apparently empty branch:

Screenshot 2024-01-23 225944

Fortunately, these keys can easily be viewed on Ubuntu by using the chntpw package. Install it first with apt-get:

Shell
sudo apt-get install chntpw

Once installed, open the Windows registry file:

BAT
cd /[MountedDrive]/Windows/System32/config
chntpw -e SYSTEM
cd \ControlSet001\Services\BTHPORT\Parameters\Keys
ls

Use ls to list the unique IDs and find the Bluetooth controller MAC address. There should only be one or two entries and it should not take long to identify the one we are interested in. Next, identify the keyboard MAC address. The MAC address should be similar to the address shown inside Ubuntu’s Bluetooth configuration panel. Some recent devices, like my Dell keyboard, will generate a new MAC address upon every new pairing attempt, which only slightly differs from the old address by a few bytes. If this happens to you, you will need to be careful in order to pick the right address.

Once you have picked the correct address, switch to the selected registry branch with cd and type hex LTK to view the value of the Long Term Key (LTK) associated with the pairing. In the following example, the controller MAC address is d4:54:8b:59:37:af and the keyboard MAC address is dc:80:ca:19:0c:00.

BAT
cd d4548b5937af
cd dc80ca190c00
(...)\Parameters\Keys\d4548b5937af\dc80ca190c00> hex LTK
Value <LTK> of type REG_BINARY (3), data length 16 [0x10]
:00000  6F 52 A9 23 F6 E9 DE 53 EE 46 06 BA 9B FF AB B7 oR.#...S.F......

Now that we have identified the LTK value, port it over to Ubuntu by editing the Bluetooth configuration file:

Shell
sudo nano /var/lib/bluetooth/[Controller Unique ID]/[Device Mac Address]/info

You will then see the contents of this file:

[General]
Name=Dell
Appearance=0x03c1
AddressType=static
SupportedTechnologies=LE;
Trusted=true
Blocked=false
WakeAllowed=true
Services=00001800-0000-1000-8000-00805f9b34fb;0000180a-0000-1000-8000-00805f9b34fb;0000180f-0000-1000-8000-00805f9b34fb;

[ConnectionParameters]
MinInterval=6
MaxInterval=7
Latency=23
Timeout=300

[IdentityResolvingKey]
Key=144EAC2271704E8D0A3D38B51B819257

[LongTermKey]
Key=354D32244559AD7D14AA8518B55B0F83
Authenticated=1
EncSize=16
EDiv=22491
Rand=7153367595019908080

[DeviceID]
Source=2
Vendor=2362
Product=10336
Version=8

Replace the Key value in the [LongTermKey] with the pairing key taken from Windows registry. For example, if the value from the Windows registry is 6F 52 A9 23 F6 E9 DE 53 EE 46 06 BA 9B FF AB B7, you should update the value in the info file to 6F52A923F6E9DE53EE4606BA9BFFB7. Take note that the names of the keys may vary slightly depending on the types of Bluetooth devices you are connecting. If necessary, repeat the same steps to also migrate the value of the IRK under over to Ubuntu, under section [IdentityResolvingKey]. If the MAC address of the device as stored in Ubuntu differs from the one stored in Windows, you will need to rename the Linux folder to reflect the value stored in Windows, which is also the latest value used by the device.

Save the configuration file and restart Blueooth services:

Shell
sudo service bluetooth restart

At this point, try to open Ubuntu’s Bluetooth configuration panel and connect to your keyboard. If you are lucky, everything will be in order and your Bluetooth keyboard should work fine.

If things don’t work yet, take note that some Bluetooth devices will generate other keys which will also need to be transferred from Windows. Navigate to the registry branch which contains the pairing info, and list all keys with ls:

ls
Node has 0 subkeys and 8 values
size     type              value name             [value if type DWORD]
16  3 REG_BINARY         <LTK>
4  4 REG_DWORD          <KeyLength>               16 [0x10]
8  b REG_QWORD          <ERand>
4  4 REG_DWORD          <EDIV>                  6398 [0x18fe]
16  3 REG_BINARY         <IRK>
8  b REG_QWORD          <Address>
4  4 REG_DWORD          <AddressType>              1 [0x1]
4  4 REG_DWORD          <AuthReq>                 45 [0x2d]

Here, you will see that there are other values such as KeyLength, ERand and EDIV that might need to be migrated. Take, for example, the value for ERand:

Value <ERand> of type REG_QWORD (b), data length 8 [0x8]
:00000  10 9F B4 C0 9C 4F ED F7                         .....O..

Windows stores the values of ERand as hexadecimal with its least significant byte first (little-endian format) whereas Ubuntu stores the value as a decimal value. We will therefore need to convert the values appropriately. In the above example, the hexadecimal value is F7ED4F9CC0B49F10, therefore the decimal value is 17865022831515180816. In the Bluetooth info configuration file, under section LongTermKey, we will then need to update the value of Rand= to this value:

[LongTermKey]
Key=354D32244559AD7D14AA8518B55B0F83
Authenticated=1
EncSize=16
EDiv=22491
Rand=17865022831515180816

Repeat the same steps for other values such as EncSize and EDiv. For EDiv, take note that if the key type is REG_DWORD, you will only need to transfer the value over without having to convert it. Only REG_BINARY and REG_QWORD values need to be converted. For EncSize, the default value of 16 should work for most devices and you usually do not have to modify this value.

Once you have confirmed that all key values are correct, restart the Bluetooth service (or reboot the machine if necessary), and you will now be able to use your Bluetooth keyboard under both Windows and Ubuntu. The same steps can be applied to other Bluetooth devices such as mice or speakers, to allow for seamless functionality across both Windows and Ubuntu operating systems.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Writer
Singapore Singapore
Since 2008, ToughDev has been publishing technical sharing articles on a wide range of topics from software development to electronics design. Our interests include, but are not limited to, Android/iOS programming, VoIP products, embedded design using Arduino/PIC microcontrollers, reverse-engineering, retro-computing, and many others. We also perform product reviews, both on new and vintage products, and share our findings with the community. In addition, our team also develops customized software/hardware solutions highly adapted to suit your needs. Contact us for more information.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Ștefan-Mihai MOGA23-Jan-24 8:42
professionalȘtefan-Mihai MOGA23-Jan-24 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.