Howto Setup Bluetooth Keyboard and Mouse in Ubuntu

Sponsored Link
If you have a Bluetooth Keyboard and Mouse here is the procedure to follow howto setup in ubuntu

We need the MAC address (e.g. 00:00:00:00:00) of the mouse and keyboard.You can use KEYBOARD_ADDR and MOUSE_ADDR where you should find the addresses for the keyboard and mouse respectively. Press the button on the mouse that makes it visible to be found by the computer. Do the same for the keyboard. Now open a terminal window and run the following command

hcitool scan

Scanning ...
KEYBOARD_ADDR Microsoft Wireless Keyboard
MOUSE_ADDR Microsoft Mouse

Adding the Keyboard and Mouse

Now we need to add the keyboard and mouse to the bluetooth configuration files. Run the following command to pop up GEdit

sudo gedit /etc/bluetooth/hcid.conf

You may be asked for your password, this is because we used sudo.

At the end of the file, add the following (replacing KEYBOARD_ADDR and MOUSE_ADDR for the keyboard and mouse MAC addresses as found earlier)

device KEYBOARD_ADDR {
name "Microsoft Wireless Keyboard";
auth enable;
encrypt enable;
}

device MOUSE_ADDR {
name "Microsoft Mouse";
}

Now you need to restart the bluetooth subsystem so that it refreshes it's configuration file.

sudo /etc/init.d/bluez-utils restart

* Restarting Bluetooth services... [ ok ]

Pairing the Devices

You now need to pair the devices with the computer. Do not press any buttons on the keyboard as we'll need to use it to enter a passcode so we can pair. Run the following command

sudo hidd --search

Searching ...
Connecting to device MOUSE_ADDR
Connecting to device KEYBOARD_ADDR

They could pair with the computer in any order, you will need to remember which one is the keyboard. As soon as Connecting to device KEYBOARD_ADDR appears you must enter a PIN code into the keyboard. It must consist of numbers not using the numpad, somewhere between 4 and 8 should be fine. Type this number in to the keyboard and press Return.

A window should pop up on your computer asking you for the number you just entered on the keyboard.

You should now be set up. The devices should automatically reconnect when they go to sleep and when your computer boots up.

Troubleshooting

If you have followed all the steps above and you find your mouse or keyboard don't automatically reconnect, we can fix it. Run the following command in a terminal

sudo gedit /etc/default/bluez-utils

Find the following lines

HIDD_ENABLED=0
HIDD_OPTIONS="..."

Change them to

HIDD_ENABLED=1
HIDD_OPTIONS="--master --connect KEYBOARD_ADDR --connect MOUSE_ADDR --server"

Now reboot and hopefully they'll automatically connect (give them a few seconds to connect after you move the mouse/press a key).

Sponsored Link

You may also like...

51 Responses

  1. Bill Cannon says:

    I bought a Microsoft 7000 bluetooth keyboard & mouse. I ran Synaptic, installed bluetooth, put batteries in the keyboard & mouse, put the dongle in my USB hub, turned on the switches (they’re on the bottom side of each device) and they worked. I didn’t do anything else. I’m running Kubuntu 6.22.9.

    sudo hcitool scan returns Device Not Available – No Such Device.

  2. bernstein says:

    well with the above stuff you might get your keyboard & mouse to work without needing the dongle…

  3. Mika says:

    “well with the above stuff you might get your keyboard & mouse to work without needing the dongle… ”

    And how would that work???? If you don’t use bluetooth-dongle, or other bluetooth receiver, then your computer can’t receive bluetooth radio-signals.

  4. jwillar says:

    installing a bluetooth ‘DELL BT keyboard & Mouse’ on a DELL laptop running Kubuntu 7.4. All goes well, the mouse connects during the ‘Pairing’ step, but the keyboad times out. This results in nothing getting setup. Why isn’t the keyboard connecting, the blue light flashes?

    jwillar

  5. Frankiee says:

    Wow cool. I’ve been looking all over for a guide like this and it works like a charm…

    Only thing…

    the bluetooth manager is found as follows in Ubuntu 7.10:
    sudo /etc/init.d/bluetooth restart
    and the configuration file:
    sudo gedit /etc/default/bluetooth

    Since i’m very new to Ubuntu I didn’t know where exyctly to put the MAC address, so this is where for people like me….

    device KEYBOARD_ADDR {
    name “00:07:61:3A:B3:BE”;
    auth enable;
    encrypt enable;
    }

    device MOUSE_ADDR {
    name “00:07:61:3C:68:A9”;
    }

  6. ferg says:

    Cheers thanks, just bought a mac mini to use as a portable linux server. Bought the wireless keyboard and mouse but then got cold feet wondering if I would be able to set them up. Your instructions are spot on. Even for this odd setup.

  7. ioan.dev says:

    Thank you for the tip 🙂
    It works nicely on a Dell Vostro 400, with Ubuntu 8.04 Hardy Heron.
    Bye.

  8. slim says:

    Nice tutorial, now I can sit on the crapper and hit next track on my keyboard!

    Thanks!

  9. Dilip Thomas Ittyera says:

    Thanx – worked like a charm.

    I am using a new Logitech diNovo Edge which is a bluetooth keyboard with a touch/scroll pad. I am using Ubuntu 8.04 Hardy Heron & the filenames were different:

    sudo /etc/init.d/bluetooth restart
    sudo gedit /etc/default/bluetooth

    Cheers.

  10. David Phillips says:

    I’ve not yet moved to Ubuntu full time. Is there any way to share a bluetooth pairing between Hardy Heron and Windows XP? It seems that when I set up Ubuntu I lose the pairing for XP, and vice-versa.

  11. john says:

    i have a dinivo desktop keyboard mouse and num pad, iv found that using a kengsington dongle, as my orignal receiver broke…..that i can use my mouse in both os, because their is no pairing key for the mouse, in respects to my media pad, it connects in vista, but as it no longer has a pass key it can’t go any further and quickly disconnects, so if there is either a way to connect in windows with out any pass keys then you could use them both in both OS, or if there is a way to connect your keyboard and media pad with the same pass key in ubuntu, then when you reboot into windows and your devices try to reconnect it will have the appriopriate keys to send out….but i have not as yet figured out how to connect a bluetooth device using keys……if anyone knows how to do this then i might be able to stop using a wired keyboard every time i go into ubuntu, which is becoming more frequent now….

  12. john says:

    well i figured out how to a secure connection in ubuntu 8.04, using hcitool auth, it then allows you to create a bonding connection between your keyboard and pc…but even if i used the same pin as in windows i cant use it in windows and visa versa if i set it up in windows with the same pin, some how creating a bond alters the connection…it no longer comes up as connecting for a second….just doesnt connect in the other os at all…does anyone know to use a bluetooth keyboard in a dual boot set up….

  13. John says:

    hcitool scan returns Device is not available: No such device

  14. Matt says:

    Ok so when I reboot my two devices stop working. When I enter “sudo gedit /etc/default/bluez-utils” (I am using hardy 8.04) it opens the file but ITS BLANK… So there is nothing for me to edit… What should I do lol.

  15. Noah says:

    Matt, try “sudo gedit /etc/default/bluetooth”

  16. solosza says:

    hi i’m new to linux and i’m trying to pair my bluetooth mouse. i tried following the directions posted here, however, when i run the:

    hcitool scan

    I just get this:

    scanning…

    then it returns to my prompt. any clue why i’m not getting the MAC Address stated in the above tutorial?

    thanks

  17. linuxwarrior says:

    Replying to Solosza, I think you need to do the scanning as root, i.e.:
    sudo hcitool scan

  18. linuxwarrior says:

    Will this work with a Logitech Mediaboard Pro ? It is a bluetooth keyboard aimed for PlayStation3 owners but I heard it works on XP.
    Does anyone got it working on Ubuntu 8.04 hardy ?

    Thanks a lot.

  19. linuxwarrior says:

    Well finally I decided to take the chance, I got my Mediaboard Pro yesterday and I have to report it WORKS perfectly following this guide.

    It even works at login (gdm) but you need to turn the keyboard off/on again.

    This howto was really helpful, I would like to add my 2 cents:
    This particular keyboard has an integrated touchpad mouse and when you scan the devices it only show as ONE bluetooth device. So I omitted the “mouse configuration sections” and it was recognized and both keyboard and mouse work PERFECT. =)

    Thanks!!

  20. talfar says:

    Hi,

    just got a Microsoft Notebook Mouse 5000 for my eeePC running ubuntu 8.04. The mouse works all right after connecting it by hand width

    hicdd –search

    but everytime a stop the computer or turn off the mouse, it won’t reconnect. I allready edited /etc/default/bluetooth and /etc/bluetoot/hicd.conf as described in this tutorial.

    Any suggestions, on what could be missing?

    regards

  21. Serola says:

    @ Talfar – I was able to pair ‘Targus Bluetooth Media Mouse for Notebook’ on ‘Ubuntu eee 8.04.1’ but I have to press ‘connect’ button of the mouse before I switch on the computer.

  22. talfar says:

    thanks Serola for your replay, but the mouse ist working just fine now. I didn’t do anything else, but a few days after I posted the messege, it startet to work without having to syncronize it every time.

  23. Serola says:

    For me the bluetooth mouse suddenly started to work just alright =)

  24. SBartsch says:

    Thanks for your manual! As bugs.launchpad.net shows, bluetooth is very buggy…
    (unplug and replug) worked for me 🙂

  25. alfonso says:

    Hi there.

    I’ve run into something very nasty. A problem pairing my keysonic BT keyboard ACK-340 BT
    When I try to connect and I run
    hidd --connect 00:18:00:00:78:86
    the computer goes back to prompt without any error, as if the pairing succeed, but it does not. And the pairing led keeps blinking on the BT keyboard, clearly showing that the keyboard has not been paired!
    According to this guide the computer should prompt me for the same passkey I just entered on the keyboard, but this doesn’t happen.
    I also tried to change /etc/bluetooth/hcid.conf setting security auto;. I thought this way to work around the problem inputting the standard PIN (1234) on my keyboard. But still the pairing doesn't work.

    The keyboard works perfectly under windows. I am using a Trust Ultra Small Bluetooth 2 USB Adapter.

    Any idea?

  26. michael says:

    Hi Alfonso,

    I am using the same Bluetooth USB adapter, the same keyboard, and run into exactly the same problem. Have you managed to solve the problem?

    On [1], I found the following command, which seems to register the agent that is supposed to pop up:
    sudo passkey-agent –default /usr/bin/bluez-pin

    Gonna try it out when I get home tonight.

    Michael

    [1] http://forum.ubuntuusers.de/topic/bluez-pin-gibts-nicht-mehr/#post-980998

  27. Alfonso says:

    Hi Michael,
    please check the following thread:
    http://ubuntuforums.org/showthread.php?t=911262

    an other user is reporting success with latest Ubuntu 8.10 (which has BlueZ 4.x).

    Unfortunately I didn’t succeed also with 8.10, so I would be very curious to know how it works for you.

    Now I’m trying directly to download latest BlueZ (4.17) from the development website (bluez.org).

    Pairing seems to work, I choose a PIN on the standard keyboard, repeat it on the wireless keyboard (and press Enter) but after, when I press keys I don’t see them on the screen.

    I’m stuck!

    Cheers,

    alfonso

  28. Leonel says:

    Hi, guys just connet the bluetooth receiver on your pc the go to the ubuntu task bar and you are going to see the bluetooth symbol click on it and select install devices but you have to press the keyboard and mouse pairing button. You have to pair one then the other, for the keyboard is going to ask you to put a number. Thanks and happy christmas.

  29. Okki says:

    Hi Alfonso,

    have you managed to solve your problem with ACK-340 BT keyboard? I have exactly the same keyboard, I followed this guide and I had the same problem.
    After a little bit googling, I found the answer on this link: http://www.math.ucla.edu/~jimc/documents/bluetooth-0703.html
    What I did is,
    After this step:
    sudo hidd –search
    I did this:
    sudo hcitool auth KEYBOARD_ADDR
    And then I typed the passkey on the keyboard, press Enter, and I got my keyboard paired.

    Okki

  30. Josef says:

    In Ubuntu 8.04, the config file changes above were not necessary for me. To get the mouse working, just:

    – Right/click the bluetooth icon and choose Preferences.
    – Switch to the Services tab.
    – Select the list item Input service. A new field appears on the bottom half of the form.
    – Click on Add. (You may need to click on the connect button of your mouse at this stage).
    – Select the mouse that should have appeared in the popup-list and click Connect.

    This worked for me at least, and I have connected to Microsoft mice and one Logitech.

    In case it can help anyone. Josef.

Leave a Reply

Your email address will not be published. Required fields are marked *