Pairing Bluetooth Keyboard That Needs code "Failed to pair: org.bluez.Error.AuthenticationFailed"

I am attempting to connect a new bluetooth keyboard (Microsoft surface erganomic keyboard) to my Ubuntu running Dell XPS 15 (2016). I am running Xubuntu 16.10 and kernel version:

root@Flere:~$ uname -a
Linux Flere 4.8.0-28-generic #30-Ubuntu SMP Fri Nov 11 14:03:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

When I try to connect the keyboard with bluetoothctl (as shown in this post: How can a Bluetooth keyboard that requires a code entry be paired in the terminal? I get an authentication failure. If I pair the same keyboard with Windows on the same machine it will ask me to type a number into the keyboard and press enter then it works. I have also tried the built in GUI tool in XFCE with no success.

root@Flere:~$ bluetoothctl 
[NEW] Controller [[mac address 1]] Flere [default]
[NEW] Device [[mac address 2]] Ergonomic Keyboard

[bluetooth]# power on
Changing power on succeeded

[bluetooth]# agent on
Agent registered

[bluetooth]# default-agent
Default agent request successful

[bluetooth]# scan on
Discovery started
[CHG] Controller [[mac address 1]] Discovering: yes
[NEW] Device [[mac address 2]] Ergonomic Keyboard
[NEW] Device [[mac address 3]] [[mac address 3 with dashes instead of colon]]

[bluetooth]# pair [[mac address 2]]
Attempting to pair with [[mac address 2]]
[CHG] Device [[mac address 2]] Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device [[mac address 2]] Connected: no

Solution 1:

You could try one of these two solutions: http://www.roydoer.com/microsoft-surface-ergonomic-bluetooth-keyboard-on-linux/ which mentions two options:

  1. getting a usb-bluetooth adapter that works nicely on linux, e.g. (google for one, i can't add the second link) IOGEAR GPU531 , it worked for me on one version of Linux Mint and didn't work with a newer one

  2. installing the driver from vendor's site, e.g. I followed instructions from http://www.slackwiki.com/Btfirmware-nonfree - apparently my lenovo w530 was having same broadcom controller as T430s.

Once the above is done, go with usual steps:

$ bluetoothctl
# power on
...
# agent on
...
# default-agent
...
# scan on
Discovery started
[CHG] Controller 5C:F3:70:81:1A:F4 Discovering: yes
[NEW] Device F6:6B:77:FF:50:4B Ergonomic Keyboard
[bluetooth]# pair F6:6B:77:FF:50:4B
Attempting to pair with F6:6B:77:FF:50:4B
[CHG] Device F6:6B:77:FF:50:4B Connected: yes
[agent] Passkey: 910013

One thing to note above: if you are using black-on-white theme in konsole, the passkey might be invisible because it's printed in white foreground. Change your console's colors to something else, say green-on-black.

Enter the passkey, hit Enter and voila - I'm typing from the MS surface ergonomic keyboard. Almost the year of Linux on desktop! ;)