[How to] Install a Bluetooth keyboard on Linux

[How to] Install a Bluetooth keyboard on Linux

Install bluetoothctl if it is not already installed.

In the terminal, run bluetoothctl:

$ bluetoothctl
Agent registered
[Bluetooth]# agent on
Agent is already registered

Start the scan:

[Bluetooth]# scan on
Discovery started
[CHG] Controller DF:53:60:0E:0A:C8 Discovering: yes
[CHG] Device ED:07:05:F7:D7:5B Icon: input-keyboard

Copy the MAC address of the keyboard (or device you want to connect to) and turn off the scan with scan off

[Bluetooth]# scan off
[CHG] Device 88:0F:10:87:00:F1 RSSI is nil
[CHG] Device ED:07:05:F7:D7:5B RSSI is nil
[CHG] Controller DC:53:60:0E:0A:C8 Discovering: no
Discovery stopped

Trust the device with scan {mac-address}:

[Bluetooth]# trust ED:07:05:F7:D7:5B
[CHG] Device ED:07:05:F7:D7:5B Trusted: yes
Changing ED:07:05:F7:D7:5B trust succeeded

Then pair it. It will show a passkey in the terminal (e.g. 620893), type it using the connected keyboard and after press Enter afterwards. It’ll look like this:

[Bluetooth]# pair ED:07:05:F7:D7:5B
Attempting to pair with ED:07:05:F7:D7:5B
[CHG] Device ED:07:05:F7:D7:5B Connected: yes
[agent] Passkey: 620893
[agent] Passkey:  20893
[agent] Passkey:   0893
[agent] Passkey:    893
[agent] Passkey:     93
[agent] Passkey:      3
[agent] Passkey:         

After confirming with Enter, the next outputs should look like this:

[CHG] Device ED:07:05:F7:D7:5B Modalias: usb:v046DpB342d4201
[CHG] Device ED:07:05:F7:D7:5B UUIDs: 00001000-0000-1000-8000-00805f9b34fb
[CHG] Device ED:07:05:F7:D7:5B UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Device ED:07:05:F7:D7:5B UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device ED:07:05:F7:D7:5B ServicesResolved: yes
[CHG] Device ED:07:05:F7:D7:5B Paired: yes
Pairing successful
[CHG] Device ED:07:05:F7:D7:5B ServicesResolved: no
[CHG] Device ED:07:05:F7:D7:5B Connected: no
[Bluetooth]# connect ED:07:05:F7:D7:5B
Attempting to connect to ED:07:05:F7:D7:5B
[CHG] Device ED:07:05:F7:D7:5B Connected: yes
Connection successful
[CHG] Device ED:07:05:F7:D7:5B ServicesResolved: yes

And that should be enough to connect your device.