Pair a new device
In Bluez4 install the bluez package to be able to pair a device from the command line with bluez-simple-agent (Bluez5 will provide the bluetoothctl
command):
bluez-simple-agent hci# xx:xx:xx:xx:xx:xx
Replace #
with the Bluetooth adapter number (e.g. hci0
) and xx:xx:xx:xx:xx:xx
with the MAC of our Bluetooth device.
The Bluetooth device should be in pairing mode of course. Enter the pin code when asked to pair the device.
Remove a paired device
If we already had paired a device and need to remove it from the database (e.g. for re-pairing) we may do so with
bluez-simple-agent hci# xx:xx:xx:xx:xx:xx remove
Note for keyboards (or mice): Until the Bluetooth keyboard is paired we may need to enter the PIN using an additional wired keyboard. See with the manual of your keyboard how the pairing is done (some expect PIN in computer first, some in keyboard first. Some may have a fixed PIN).
After pairing, we connect the keyboard with:
sudo bluez-test-input connect xx:xx:xx:xx:xx:xx
To allow auto-connection after a reboot we can add the device to the trusted devices:
sudo bluez-test-device trusted xx:xx:xx:xx:xx:xx yes