Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've been trying to pair up my bluetooth keyboard with my computer after reinstalling from a standard ubuntu 12.04 to a minimal install.

In the minimal install I have no gui, so I've been trying to use the various command line tools available, but I can't figure out how the pairing is supposed to go. Pairing when I had a gui worked flawlessly.

I've asked for help here: http://ubuntuforums.org/showthread.php?p=12234695

No one has replied but a lot of details of my situation is available there.

How is one supposed to pair bluetooth devices from the command line?

share|improve this question

2 Answers 2

Pair a new device

Provided we already had installed the bluez Install bluez package we will be able to pair a device from the command line with bluez-simple-agent:

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.

  • To get the number of our adapter we may issue:

    hciconfig
    
  • The MAC of devices can be scanned for with the following command:

    hcitool scan
    

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 may have to connect the keyboard with

sudo bluez-test-input connect xx:xx:xx:xx:xx:xx 
share|improve this answer
    
Very useful and tested to work. –  hexafraction Sep 12 '12 at 19:31
    
I very much appreciate the answer, unfortunately I've done that exact thing without getting the keyboard to work. When pairing using the gui the computer used to suggest a pin which I then wrote using the keyboard. This is not what happens using bluez-simple-agent. It instead asks for a pin. I don't have a static pin for the keyboard, and suppling the one I give to bluez-simple-agent through the keyboard does nothing to aid the pairing. –  azzid Sep 12 '12 at 22:21
2  
After pairing, you also need bluez-test-input connect xx:xx:xx:xx:xx:xx to be able to use the paired keyboard. (doesn't help azzid if stuck on pairing, but for other readers of this question) –  Beni Cherniavsky-Paskin Nov 3 '13 at 2:41
    
Your comment is a good addendum to the really nice answer which shall be extended with that information. –  flyer Nov 3 '13 at 3:17

After searching a lot I've found two solutions. One is bluetoothctl which is performs exactly what you are looking for. You can do almost anything from command line :) Because I'm lazy and my memory is still on HDD I need some applet as well, so I've installed bluedevil on my mate desktop :) it is working except scanning, but it is fine like this

share|improve this answer
    
Since it's been more than two years I no longer have the setup to verify your suggestion, but thanks anyway! =) –  azzid Oct 7 at 17:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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