Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Ubuntu 11.10 and try to connect to a Bluetooth device from the command line but I always need to enter the PIN in a graphical dialog box. The commands I use:

root@ubuntu:~# hcitool scan
Scanning ...
00:00:00:00:00:00   device
root@ubuntu:~# rfcomm connect 0 00:00:00:00:00:00 1

And after this, the enter PIN dialog appears.

Is there any way to keep the interaction in the command line? In my environment it is not allowed to use GUIs or require the user to enter PINs. Btw, the PIN is always the same but the MAC will change from time to time.

share|improve this question
There is a similar question for paired devices at – lumbric Jan 4 '12 at 13:22
That question is concerned with previously paired devices. In my case I need to control the pairing process. – allprog Jan 4 '12 at 15:34
up vote 1 down vote accepted

What you are looking for is a bluetooth agent, which validates the PIN. You'll find a very straightforward one at here, written in python. You just have to change the end of RequestPinCode to 'return "0000"' for instance.

share|improve this answer
Great, thanks! What should I do if it returns this exception: dbus.exceptions.DBusException: org.bluez.Error.AlreadyExists: Already Exists. I suppose there is already an agent but how can I unregister that? – allprog Jan 4 '12 at 15:14
It means there already is an agent running. Should be something like blueman (blueman-manager). 'killall blueman-manager' should do the trick. – Ravachol Jan 4 '12 at 15:16
Beautiful! It works! I had to kill the blueman-applet and started my hacked agent. blueman-manager is useful to remove the pairings. – allprog Jan 4 '12 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .