Linux command line howto accept pairing for bluetooth device without pin

Roman A. Taycher picture Roman A. Taycher · Oct 15, 2012 · Viewed 112.7k times · Source

Is there a way to pair a device in linux without requiring a pin(for testing purposes so I need it to be done w/out human interaction, assuming you have root access)?

bluez-simple-agent seems to require a pin except with some simple devices such as mice.

Answer

Paul Poulsen picture Paul Poulsen · Oct 24, 2012

Entering a PIN is actually an outdated method of pairing, now called Legacy Pairing. Secure Simple Pairing Mode is available in Bluetooth v2.1 and later, which comprises most modern Bluetooth devices. SSPMode authentication is handled by the Bluetooth protocol stack and thus works without user interaction.

Here is how one might go about connecting to a device:

# hciconfig hci0 sspmode 1
# hciconfig hci0 sspmode
hci0:   Type: BR/EDR  Bus: USB
BD Address: AA:BB:CC:DD:EE:FF  ACL MTU: 1021:8  SCO MTU: 64:1
Simple Pairing mode: Enabled
# hciconfig hci0 piscan
# sdptool add SP
# hcitool scan
    00:11:22:33:44:55    My_Device
# rfcomm connect /dev/rfcomm0 00:11:22:33:44:55 1 &
Connected /dev/rfcomm0 to 00:11:22:33:44:55 on channel 1
Press CTRL-C for hangup

This would establish a serial connection to the device.