3

I have an Apple Wireless Keyboard and Trackpad (2 AA battery version of both, not the latest models that charge via a lightning cable), running Ubuntu 15.10 64-bit on an Intel NUC6i5SYK, kernel 4.2.0-27 (stock). I've got the Wireless Trackpad working fine with no issues. However, I can't for the life of me get the keyboard working. I've followed several guides and have managed to pair this keyboard via bluetoothctl, entering the PIN and seeing successfully paired. But it simply won't connect... it's paired but won't connect.

I do see the following error using journalctl:

Authentication attempt without agent Access denied: org.bluez.Error.Rejected

The same keyboard works flawlessly in Windows 10, so I know it's not the bluetooth controller or keyboard itself. The trackpad also works in Windows 10, and I used this trick to copy the bluetooth keys from the Windows registry to the bluetooth configuration in Linux: How can I avoid having to pair my bluetooth mouse all the time? https://superuser.com/questions/229930/finding-bluetooth-link-key-in-windows-7-to-double-pair-a-device-on-dualboot-com

Again, the trackpad works without issues in both Windows and Linux using this approach of mirroring the Bluetooth key. Even forgetting the goal of pairing the keyboard in both Windows and Linux, and setting up the keyboard with a new pairing, the keyboard won't pair via the GUI interface. I had to use bluetoothctl and even that wasn't reliable.

Are there known issues with bluetooth drivers in 4.2, or perhaps a bug with the Apple Wireless Keyboard specifically?

4

I solved the problem in a similar way compared to phireph0x, but whenever I tried to use:

pair [dev]

This would give me an authentication error. So I restarted the whole process from the beginning and this time instead of using pair, I used:

connect [dev]

Next thing was input the PIN in my computer, and then type the same PIN in the keyboard. Worked like a charm. I am now using the bluetooth keyboard!

It is also worth trying to setup the agent before connecting (also inside the bluetoothctl):

agent KeyboardDisplay
default-agent
  • +1 for likely relevant answer. Also, instead of leaving "thanks" note in the answer, consider to vote up the useful answer instead. You can do so, once you have enough reputation. – clearkimura Feb 18 '16 at 14:16
4

This was a pain in the button to get working. I really wanted to make a precise answer but I think the tech is a little flaky and the tools are a little trying. I did it once successfully, went to do it again from my notes to make sure my answer was sound and it took me another hour of trying to get it to take. These are the steps I followed on Ubuntu 16.04 (derived from @phireph0x and @danielfbm's answers).

  1. Install bluetoothctl: sudo apt install bluetoothctl
  2. Run bluetoothctl: bluetoothctl. You should see an initial list of connected devices like so: [NEW] Controller 23:34:17:64:AF:0E ChromeLinux_A00F [default] [NEW] Device 00:19:32:D3:38:01 Pico the Keyboard It's ok if you don't see the Apple keyboard initially. You should see it by the end of step 5 in the next section.

The remaining steps are from the bluetoothctl command prompt:

  1. Set the agent: agent KeyboardDisplay default-agent
  2. Turn off the Bluetooth keyboard by removing the batteries. Hold the power button in and wait 10 seconds.
  3. Scan for devices: scan on.
  4. Turn on the Bluetooth keyboard by reinserting the batteries holding the power button in for 10 seconds. If you don't see the keyboard power light blinking continuously, it's not trying to pair. Try again.
  5. Wait for your Bluetooth keyboard to appear in bluetoothctl. This will happen asynchronously while you wait at the prompt. My keyboard popped up after 20-30 seconds.
  6. Remove any previous attempts: remove 00:19:32:D3:38:01. Replace 00:19:32:D3:38:01 with your keyboard that popped up in step 5.
  7. Wait for your Bluetooth keyboard to pop up again. This will probably take 20-30 seconds.
  8. Make a connection and pair the Bluetooth keyboard: connect 00:19:32:D3:38:01. Replace 00:19:32:D3:38:01 with your keyboard that popped up in step 5 and 7.
  9. If you're on track, you should see your prompt change from: [bluetooth]# to [Pico the keyboard]:.
  10. Now, on your Bluetooth keyboard, type 1234 and press enter. That's five keystrokes on the Bluetooth keyboard: 1, 2, 3, 4, and the carriage return.
  11. If that worked, you should see the prompt change to: [agent] Enter the pin code:
  12. On your other keyboard, not your Bluetooth keyboard, type 1234 and press enter.

If all works well, you should see Connection successful. If the connection failed, turn off the keyboard and try again from step 2.

Troubleshooting:

  • The keyboard seems to mate for life and will try to pair with any Macs it has paired with in the past. Make sure they're off.
  • Restart your PC if all else fails. I was surprised to find that I didn't seem to have much trouble with the Ubuntu Bluetooth stack. I did restart a couple times but I don't think it's what got things working in the end.
3

Wow. This was a super pain to set up. After following the tips in this thread (on Ubuntu Mate 16.04), I found I also needed to modify some configuration files as suggested here in the Debian wiki

/etc/default/bluetooth - Default HID bluez setting - enable for mice and keyboards

HID2HCI_ENABLED=1

/etc/bluetooth/hcid.conf - HCI bluez settings - configure static device information [Replace the device address with the address shown by bluetoothcl]

device 00:1E:52:FB:68:55 {
    name "Apple Wireless Keyboard";
    auth enable;
    encrypt enable;}

It seems there has been some churn in the Ubuntu bluetooth stack along the way and many of the older tips'n'tricks for bluetooth fixes seem not to help any longer.

2

I eventually got this working, but note that the initial pairing/connection process (at least for me) was extremely flakey. So it may take several attempts before you can successfully establish a connection. First, I had to completely remove the keyboard device from the Bluetooth configuration using bluetoothctl:

remove [dev]

Then I reset the keyboard's stored pairing configuration by removing the battery, waiting 10 seconds, replacing the battery, and holding down the power button until the keyboard goes into discoverable mode. Then add the device once more using bluetoothctl:

trust [dev]
pair [dev]

The other gotcha is the keyboard is initially in Numlock mode when connected to Bluetooth, as described Apple wireless keyboard does not work and elsewhere. You can use the Fn+F6 trick, but this isn't persistent between reboots. To permanently fix this, you must set the 'Default numeric keypad keys' as described https://help.ubuntu.com/community/NumLock However, in Ubuntu 15.0 this Settings->Keyboard Layout configuration option is no longer present. So you must install gnome-tweak-tools:

sudo apt-get install gnome-tweak-tool

And set the option in Typing->Miscellaneous compatibility options.

Hope this helps someone avoid the hours of anguish in getting this keyboard working properly.

  • THIS! I have an original apple wireless (A1018) that I could not get to pair with a newer 4.x kernel until I combined this tip with the detailed steps in @stephen niedzelski's answer. The key seemed to be the explicit "trust" combined with the four-character manually-entered PIN code. – Chris Cleeland Apr 19 '17 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.