Ubuntu 14.10中的蓝牙链接密钥存储在哪里?


10

我正在尝试为Ubuntu 14.10中的设备设置特定的蓝牙链接密钥,但无法找到它们的存储位置。
目的是让蓝牙鼠标在Ubuntu和Windows中均可工作,而无需在切换操作系统后重新配对。
我在AskUbuntu上找到的所有答案都指出密钥已存储在/var/lib/bluetooth/<mac_address>/linkkeys其中,至少在13.10之前一直如此,但是在14.10中,干净的桌面安装中缺少此文件,并且手动创建它无效,被忽略。蓝牙。

编辑:似乎鼠标不会发出配对请求,并且在这种情况下不会存储链接键。但是,在Windows中连接鼠标,然后在Ubuntu中重新启动会导致蓝牙连接失败(并且需要删除鼠标并将其重新添加到蓝牙设备列表中),因此肯定存在一些密钥交换/身份验证会阻止在两个操作系统中共享鼠标。问题仍然存在,在连接此鼠标时如何强制蓝牙保存并使用保存的链接键?

硬件细节:

  • Microsoft蓝牙笔记本鼠标5000
  • 413c:8161 Dell Computer Corp.Wireless 365 Bluetooth(Broadcom BCM2046B1)

下面的两个日志显示,对于可配对的设备(手机),密钥存储在linkkeys文件中。鼠标不是这种情况。我知道较早的蓝牙版本也曾用于保存鼠标的链接键,因为在Askubuntu和ubuntuforums上有很多答案/教程,涉及将链接键从Windows复制到Ubuntu的特定目的,目的是在两个操作系统之间共享鼠标。

这是鼠标发现和连接设置的蓝牙日志:

    bluetoothd[15615]: plugins/mgmtops.c:mgmt_start_discovery() index 0
    bluetoothd[15615]: Discovery session 0x7feb52b14130 with :1.137 activated
    bluetoothd[15615]: src/adapter.c:session_ref() 0x7feb52b14130: ref=1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 10 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() 
    bluetoothd[15615]: plugins/mgmtops.c:start_discovery_complete() hci0 type 1 status 0
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 8 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_discovering() Controller 0 type 1 discovering 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 25 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_device_found() hci0 addr DE:AD:BE:EF:00:00, rssi -43 flags 0x0003 eir_len 5
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_confirm_name() hci0 bdaddr DE:AD:BE:EF:00:00 name_known 0
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 16 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() 
    bluetoothd[15615]: Unknown command complete for opcode 37
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 61 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_device_found() hci0 addr DE:AD:BE:EF:00:00, rssi -43 flags 0x0000 eir_len 41
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 8 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_discovering() Controller 0 type 1 discovering 0
    bluetoothd[15615]: src/adapter.c:adapter_set_discovering() hci0 restarting discovery, disc_sessions 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_start_discovery() index 0
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 10 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() 
    bluetoothd[15615]: plugins/mgmtops.c:start_discovery_complete() hci0 type 1 status 0
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 8 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_discovering() Controller 0 type 1 discovering 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 25 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_device_found() hci0 addr DE:AD:BE:EF:00:00, rssi -43 flags 0x0003 eir_len 5
    bluetoothd[15615]: src/adapter.c:session_unref() 0x7feb52b14130: ref=0
    bluetoothd[15615]: src/adapter.c:session_remove() Discovery session 0x7feb52b14130 with :1.137 deactivated
    bluetoothd[15615]: src/adapter.c:session_remove() Stopping discovery
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_stop_discovery() index 0
    bluetoothd[15615]: Stopping discovery
    bluetoothd[15615]: src/adapter.c:create_device() DE:AD:BE:EF:00:00
    bluetoothd[15615]: src/adapter.c:adapter_create_device() DE:AD:BE:EF:00:00
    bluetoothd[15615]: src/device.c:device_create() Creating device /org/bluez/15615/hci0/dev_DE:AD:BE:EF:00:00
    bluetoothd[15615]: src/device.c:btd_device_ref() 0x7feb52b15680: ref=1
    bluetoothd[15615]: src/device.c:device_set_temporary() temporary 1
    bluetoothd[15615]: src/device.c:btd_device_ref() 0x7feb52b15680: ref=2
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 10 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() 
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() stop_discovery complete
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 8 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_discovering() Controller 0 type 1 discovering 0
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 65 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_device_connected() hci0 device DE:AD:BE:EF:00:00 connected eir_len 46
    bluetoothd[15615]: src/adapter.c:adapter_get_device() DE:AD:BE:EF:00:00
    bluetoothd[15615]: src/device.c:device_probe_drivers() Probing drivers for DE:AD:BE:EF:00:00
    bluetoothd[15615]: input/manager.c:hid_device_probe() path /org/bluez/15615/hci0/dev_DE:AD:BE:EF:00:00
    bluetoothd[15615]: src/device.c:btd_device_ref() 0x7feb52b15680: ref=3
    bluetoothd[15615]: input/device.c:input_device_new() Registered interface org.bluez.Input on path /org/bluez/15615/hci0/dev_DE:AD:BE:EF:00:00
    bluetoothd[15615]: src/device.c:device_set_temporary() temporary 0
    bluetoothd[15615]: src/device.c:btd_device_unref() 0x7feb52b15680: ref=2

这是手机配对的蓝牙日志(要求用户验证两个设备上显示的代码):

    bluetoothd[15615]: plugins/mgmtops.c:mgmt_start_discovery() index 0
    bluetoothd[15615]: Discovery session 0x7feb52b14ca0 with :1.138 activated
    bluetoothd[15615]: src/adapter.c:session_ref() 0x7feb52b14ca0: ref=1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 10 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() 
    bluetoothd[15615]: plugins/mgmtops.c:start_discovery_complete() hci0 type 1 status 0
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 8 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_discovering() Controller 0 type 1 discovering 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 64 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_device_found() hci0 addr DE:AD:BE:EF:01:01, rssi -52 flags 0x0000 eir_len 44
    bluetoothd[15615]: src/adapter.c:session_unref() 0x7feb52b14ca0: ref=0
    bluetoothd[15615]: src/adapter.c:session_remove() Discovery session 0x7feb52b14ca0 with :1.138 deactivated
    bluetoothd[15615]: src/adapter.c:session_remove() Stopping discovery
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_stop_discovery() index 0
    bluetoothd[15615]: Stopping discovery
    bluetoothd[15615]: src/adapter.c:adapter_create_device() DE:AD:BE:EF:01:01
    bluetoothd[15615]: src/device.c:device_create() Creating device /org/bluez/15615/hci0/dev_DE:AD:BE:EF:01:01
    bluetoothd[15615]: src/device.c:btd_device_ref() 0x7feb52b17cd0: ref=1
    bluetoothd[15615]: src/device.c:device_set_temporary() temporary 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_create_bonding() hci0 bdaddr DE:AD:BE:EF:01:01 io_cap 0x01
    bluetoothd[15615]: src/device.c:bonding_request_new() Requesting bonding for DE:AD:BE:EF:01:01
    bluetoothd[15615]: src/device.c:bonding_request_new() Temporary agent registered for DE:AD:BE:EF:01:01 at :1.138:/org/bluez/agent/wizard
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 10 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() 
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() stop_discovery complete
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 8 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_discovering() Controller 0 type 1 discovering 0
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 37 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_device_connected() hci0 device DE:AD:BE:EF:01:01 connected eir_len 18
    bluetoothd[15615]: src/adapter.c:adapter_get_device() DE:AD:BE:EF:01:01
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 18 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_user_confirm_request() hci0 DE:AD:BE:EF:01:01 confirm_hint 0
    bluetoothd[15615]: src/adapter.c:adapter_get_device() DE:AD:BE:EF:01:01
    bluetoothd[15615]: src/device.c:new_auth() Requesting agent authentication for DE:AD:BE:EF:01:01
    bluetoothd[15615]: src/agent.c:agent_request_confirmation() Calling Agent.RequestConfirmation: name=:1.138, path=/org/bluez/agent/wizard, passkey=436733
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_confirm_reply() index 0 addr DE:AD:BE:EF:01:01 success 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 16 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() 
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() user_confirm_reply complete
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 32 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_new_link_key() Controller 0 new key of type 5 pin_len 0
    bluetoothd[15615]: src/adapter.c:adapter_get_device() DE:AD:BE:EF:01:01
    bluetoothd[15615]: src/event.c:btd_event_link_key_notify() storing link key of type 0x05
    bluetoothd[15615]: src/device.c:device_set_bonded() bonded 1
    bluetoothd[15615]: src/device.c:device_set_temporary() temporary 0
    bluetoothd[15615]: src/adapter.c:adapter_get_device() DE:AD:BE:EF:01:01
    bluetoothd[15615]: src/device.c:device_bonding_complete() bonding 0x7feb52b2d270 status 0x00
    bluetoothd[15615]: src/device.c:device_bonding_complete() Proceeding with service discovery
    bluetoothd[15615]: src/device.c:btd_device_ref() 0x7feb52b17cd0: ref=2
    bluetoothd[15615]: src/agent.c:agent_release() Releasing agent :1.138, /org/bluez/agent/wizard
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() cond 1
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_event() Received 16 bytes from management socket
    bluetoothd[15615]: plugins/mgmtops.c:mgmt_cmd_complete() 
    bluetoothd[15615]: plugins/mgmtops.c:pair_device_complete() hci0 DE:AD:BE:EF:01:01 pairing complete status 0
    bluetoothd[15615]: src/adapter.c:adapter_get_device() DE:AD:BE:EF:01:01
    bluetoothd[15615]: src/device.c:device_bonding_complete() bonding (nil) status 0x00

我有14.04,目录已经存在,但是mac地址是我内部蓝牙的地址,而linkkeys是空的……
Fabby 2014年

我有14.04并升级到14.10,现在找不到目录。我和您有同样的问题,想为BT鼠标设置链接键。
阿拉斯霍

Answers:


3

一段时间后,我终于解决了我面临的问题。我仍然没有找到第一个问题的答案(我无法确定此特定bluez / adapter / peripheral组合的链接密钥存储在哪里),但我确实发现bluez会读取linkkeys文件(如果存在),并将使用文件中的密钥。

因此,即使链接密钥在配对后可能未写入文件中,也可以通过手动将这些密钥添加到linkkeys文件中来覆盖它们。

正确设置密钥类型很重要,否则密钥将被忽略。

作为参考,此处显示了适用于我的情况的密钥类型:https : //askubuntu.com/a/246791/352576


1

Ubuntu 13.10使用bluez 4.98、14.04和14.10使用4.101

两种版本都使用相同的选项(--localstatedir = / var)进行编译

我正在使用14.04,文件在那里,如果我删除或添加设备,则/ var / lib / bluetooth /(myadapteraddress)/ linkkeys文件将相应更新。

我在14.10系统上进行了测试,添加了BT设备,并创建了/ var / lib / bluetooth /(adapteraddress)/ linkkeys文件

也许您正在使用bluez的较新版本。

bluez新版本的架构(我认为从5开始):

/var/lib/bluetooth/<adapter address>/<remote device address>/info

在新的bluez版本的设置存储文档中,我发现了这一点:

http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/settings-storage.txt

...

Storage directory structure

There is one directory per adapter, named by its Bluetooth address, which
contains:
 - a settings file for the local adapter
 - an attributes file containing attributes of supported LE services
 - a cache directory containing:
    - one file per device, named by remote device address, which contains device name
 - one directory per remote device, named by remote device address, which contains:
    - an info file
- an attributes file containing attributes of remote LE services
- a ccc file containing persistent Client Characteristic Configuration
  (CCC) descriptor information for GATT characteristics

So the directory structure is:

/var/lib/bluetooth/<adapter address>/

    ./settings
    ./attributes
    ./cache/
        ./<remote device address>
        ./<remote device address>
        ...
    ./<remote device address>/
        ./info
        ./attributes
        ./ccc
    ./<remote device address>/
        ./info
        ./attributes
    ...

...

Info file format

...

[LinkKey] group contains:

  Key           String      Key in hexadecimal format

  Type          Integer     Type of link key

  PINLength     Integer     Length of PIN

...

无论如何,bluez应该将文件存储在/ var / lib / bluetooth中

如果使用此命令

bluetoothd --version

你得到4.101?


1
是的,蓝牙版本为4.101。该var/lib/bluetoooth/<adapter address>文件夹存在,但没有链接密钥文件,也没有任何子目录。蓝牙设备已配对并且可以正常工作,因此密钥存储在某处,但绝对不在该处。也许Ubuntu版本将密钥存储在其他位置,而我正在尝试找出位置。我正在使用标准的14.10桌面安装,通过蓝牙指示器进行配对,没有任何花哨的地方。
ATAKAMA 2014年

1
在我看来,某些蓝牙适配器具有硬件密钥存储。Ubuntu蓝牙是否可能仅将链接密钥存储在适配器内存中,而不存储在文件系统中?适配器为:413c:8160戴尔计算机公司基于Broadcom BCM2046的无线365蓝牙
ATAKAMA 2014年

您是否尝试过配对其他设备(手机)?...稍后,我将在另一台PC中尝试14.10
J.Serra 2014年

我只是配对了从未与该适配器配对的手机(在Ubuntu和Windows中均未配对)。linkkeys文件已创建。然后,我尝试再次配对鼠标,将其配对,但是其链接键未添加到文件中。如何使蓝牙读取文件中的链接密钥而不使用适配器中的链接密钥(大概是这样做的)?
ATAKAMA 2014年

很好奇...也许如果您消除Windows中的设备,ubuntu就会创建文件。
J.Serra 2014年

0

/ var / lib / bluetooth / {bluetoothaddr} / linkkeys

其中{bluetoothaddr}是您的蓝牙接口(您应该只有一个,它看起来像mac地址)

文件格式为{remoteaddr} {128位链接密钥} {type}。

20:12:03:22:EE:0E C21D3A69DEA0A8C629F1BB5D12AEEA79 4 0
00:18:94:68:3E:90 EC02519ED656DB87B7F152E899F8A810 0 4
00:21:3F:3E:2E:6C 948A0EF91FA8E9EB9032CE775BF8E0B0 0 4

请仔细阅读问题文字。该文件在14.10安装中不再存在。在文件系统中的任何地方都没有linkkeys文件。密钥存储在其他位置。问题是在哪里。
ATAKAMA 2014年

在我安装(未更新)14.10的新笔记本电脑上,仍然有我所描述的文件。蓝牙4.101。尝试配对新设备时,syslog上显示什么消息?
Xavier 2014年

我编辑了问题,并添加了一些日志,以比较此鼠标的发现和连接设置与已保存其链接键的手机的连接设置。
ATAKAMA 2014年

0

在Debian Jessie&我假设Ubuntu中,您也可以手动设置要使用的PIN。

  1. 按照https://askubuntu.com/a/246791/352576上的描述进行操作,以获取Windows密钥。
  2. /var/lib/bluetooth/XX:XX:XX:XX:XX:AA(这里XX: ... :AA是你的电脑的BT适配器的MAC)应该包含您的BT鼠标/键盘的MAC一个目录(我将它表示为XX: ... :BF,和文件配置,和设置。
  3. XX: ... BF有一个文件info由root拥有,权限RW根。没有其他权限。-内容应为:

    [LinkKey] 
    Key=A7XXXXXXXXXXXXXXXXXXXXXXXXXXXX89 
    Type=4
    PINLength=0
    
    [General]
    Name=yourMouseName
    Class=0x002580
    SupportedTechnologies=BR/EDR;
    Trusted=true
    Blocked=false
    Services=00001000-0000-1000-8000-00805f9b34fb;00001124-0000-1000-8000-00805f9b34fb;00001200-0000-1000-8000-00805f9b34fb;
    
    [DeviceID]
    Source=2
    Vendor=1133
    Product=45069
    Version=1792
    

    请注意,密钥长度为16个字节长。

将linkkeys文件粘贴在这些目录中并没有帮助我-尽管我将它们放在适当的位置。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.