Cannot pair the generic keyboard via automatic PIN

bluetoothkeyboard

I am using Xubuntu, pure Xfce, 64-bit.

The problem:

I have tried 2 ways; both have failed for different reasons:
(1) the commandline way (see below) fails because at no stage does it actually ask for a pin verification. (2) the GUI way using the "Bluetooth" utility (that sounds generic but it's what the tool is actually called and how it is catalogued under Synaptic) fails because the keyboard is unresponsive when the pin is requested by Bluetooth.

How do I pair my device properly with the use of a automatically generated PIN?

I really don't care if the solution will be GUI-based or not, as long as you can get it to pair the secure way, with a PIN. I don't want to be using my keyboard on discovery mode all the time for obvious reasons relating to security.

Details of my failed efforts:

I followed the directions on http://ubuntuforums.org/showthread.php?t=224673 in order to activate a generic bluetooth device (http://www.ebay.com/itm/Mini-Bluetooth-Keyboard-PC-Mac-iPhone-Nokia-PDA-HTC-/110653444332?pt=PCA_Mice_Trackballs&hash=item19c37590ec), which succeeded. Except come the part where I am supposed to be asked for a password, I wasn't. This is a bit disturbing, I think to myself. Anyone in the neighborhood could've in this manner connected to my keyboard and started key-logging my activities.

Anyhow this is how I did it:

peter@peter-xfce:~$ hcitool scan
Scanning ...
peter@peter-xfce:~$ hcitool scan
Scanning ...
    00:12:A1:11:04:E9   Bluetooth Keyboard
peter@peter-xfce:~$ gksudo mousepad /etc/bluetooth/hcid.conf
peter@peter-xfce:~$ sudo gedit /etc/default/bluetooth
peter@peter-xfce:~$ sudo /etc/init.d/bluetooth restart
 * Stopping bluetooth                                                    [ OK ] 
 * Starting bluetooth                                                    [ OK ] 
peter@peter-xfce:~$ sudo hidd --connect 00:12:A1:11:04:E9
sudo: hidd: command not found
peter@peter-xfce:~$ hidd --connect 00:12:A1:11:04:E9
The program 'hidd' is currently not installed.  You can install it by typing:
sudo apt-get install bluez-compat

[at this point bluez-compat is installed]

peter@peter-xfce:~$ sudo hidd --connect 00:12:A1:11:04:E9
peter@peter-xfce:~$ 

[can now type using the bluetooth keyboard]

Again this is unacceptable. I don't consider that the device was paired securely because no pin was requested.

Alternatively via GUI:

enter image description here

But the keyboard is unresponsive so I cannot enter to PIN when requested.

Best Answer

I just got the pairing to work myself in linux... I did the following:

I'm on Linux Mint

First I got the name of the bluetooth device using hcitool inq while the device was discoverable:

$ hcitool inq
Inquiring ...
00:1F:20:3D:7A:4A        clock offset: 0x14b4    class: 0x002540

Then I got identified the device:

$ hcitool scan
Scanning ...
        00:1F:20:3D:7A:4A        Logitech K760

This is the keyboard I was trying to connect. :) Next I needed the name of the bluetooth adapter as a device:

$ hciconfig
hci0:     Type: BR/EDR  Bus: USB
          BD Address: E0:2A:82:02:5D:EF   ACL MTU: 1021:8  SCO MTU: 64:1
          UP RUNNING PSCAN ISCAN
          RX bytes:5150 ac1:0 sco:0 events:262 errors:0
          TX bytes:1272 ac1:0 sco:0 commands:116 errors:0

Armed with this information, we can now use the simple agent:

$ bluez-simple-agent hci0 00:1F:20:3D:7A:4A
DisplayPasskey (/org/bluez/791/hci0/dev_00_1F_20_3D_7A_4A, 123456)

At this point, you can type the passkey which is the number after the comma in the parenthesis, on the bluetooth keyboard. then hit enter and you'll get:

Release
New Device (/org/bluez/791/hci0/dev_00_1F_20_3D_7A_4A)

Next we need to link up the keyboard to the input system:

hidd --connect 00:1F:20:3D:7A:4A

At this point I realized I made two mistakes: the tool wasn't installed...

$ sudo aptitude install bluez-compat
<all sorts of wonderful stuff you don't need to see here>

... and I didn't run as root:

$ hidd --connect 00:1F:20:3D:7A:4A
HID create error 13 (permission denied)
$ sudo !! # yes if you put this command in
          # after failing to run a command that requires elevation,
          # it will run as though sudo'ed, the shell subs !! for
          # the last command
sudo hidd --connect 00:1F:20:3D:7A:4A
Can't get device information: host is down

At this point, the keyboard had lost "discoverable" status (the blue light wasn't blinking anymore, so I pressed the discover key, then on the old keyboard, hit the up arrow, and enter to repeat the command:

$ sudo hidd --connect 00:1F:20:3D:7A:4A
$ _

The command gives no output if it succeeds, the device is now paired, and ready to use as a keyboard.

Enjoy!

Related Question