Gdzie są przechowywane klucze łącza Bluetooth w Ubuntu 14.10?


10

Próbuję ustawić określone klucze łącza Bluetooth dla urządzenia w Ubuntu 14.10, ale nie jestem w stanie znaleźć, gdzie są przechowywane.
Celem jest, aby mysz bluetooth działała zarówno w systemie Ubuntu, jak i Windows, bez konieczności ponownego parowania po zmianie systemu operacyjnego.
Wszystkie odpowiedzi, które znalazłem w AskUbuntu, stwierdzają, że klucze są przechowywane /var/lib/bluetooth/<mac_address>/linkkeysi tak było przynajmniej do 13.10, ale w 14.10 brakuje tego pliku w czystej instalacji na pulpicie i ręczne utworzenie go nie ma żadnego efektu, jest ignorowane przez bluetoothd.

EDYCJA: Wygląda na to, że mysz nie wydaje żądania parowania i klucze łącza nie są w tym przypadku przechowywane. Jednak podłączenie myszy w systemie Windows, a następnie ponowne uruchomienie w Ubuntu powoduje awarię połączenia bluetooth (i mysz musi zostać usunięta i ponownie dodana do listy urządzeń bluetooth), więc na pewno dzieje się pewna wymiana kluczy / uwierzytelnianie, które zapobiega myszy z udostępniania w obu systemach operacyjnych. Pozostaje pytanie, jak mogę zmusić bluetoothd do zapisania i używania zapisanych klawiszy łącza podczas podłączania tej myszy?

Szczegóły sprzętu:

  • Mysz Microsoft Bluetooth Notebook 5000
  • 413c: 8161 Dell Computer Corp. Wireless 365 Bluetooth (Broadcom BCM2046B1)

Dwa dzienniki poniżej pokazują, że w przypadku parowalnego urządzenia (telefonu komórkowego) klucze są przechowywane w pliku linkkeys; tak nie jest w przypadku myszy. Wiem, że starsze wersje bluetoothd również zapisywały klucze linków dla myszy, ponieważ istnieje wiele odpowiedzi / samouczków na askubuntu i ubuntuforums na temat kopiowania kluczy linków z Windows do Ubuntu w konkretnym celu udostępniania myszy między dwoma systemami operacyjnymi.

Oto dziennik bluetoothd dotyczący wykrywania myszy i konfiguracji połączenia:

    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

Oto dziennik bluetoothd do parowania telefonu komórkowego (użytkownik jest proszony o sprawdzenie poprawności kodu wyświetlanego na obu urządzeniach):

    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

Mam 14.04 i katalog istnieje dla mnie, ale adres MAC to adres mojego wewnętrznego bluetooth, a klawisze łącza są puste ...
Fabby,

Miałem 14.04 i zaktualizowałem do 14.10, teraz nie mogę znaleźć katalogu. Mam ten sam problem, co Ty, chcąc ustawić klucz połączenia dla myszy BT.
Alasjo

Odpowiedzi:


3

Po pewnym czasie w końcu rozwiązałem problem, z którym się spotkałem. Nadal nie znalazłem odpowiedzi na początkowe pytanie (nie mogłem ustalić, gdzie przechowywane są klucze łącza dla tej konkretnej kombinacji bluez / adapter / urządzenie peryferyjne), ale dowiedziałem się, że bluez odczyta plik kluczy, jeśli jest obecny, i użyje kluczy z pliku.

Więc nawet jeśli klucze parowania mogą nie zostać zapisane w pliku po sparowaniu, możliwe jest zastąpienie tych kluczy przez ręczne dodanie ich do pliku linkkeys.

Ważne jest, aby typ klucza był ustawiony poprawnie, w przeciwnym razie klucz zostanie zignorowany.

W celach informacyjnych typ klucza, który działał w moim przypadku, pokazano tutaj: https://askubuntu.com/a/246791/352576


1

Ubuntu 13.10 używa bluez 4.98, 14.04 i 14.10 używa 4.101

Obie wersje zostały skompilowane z tą samą opcją (--localstatedir = / var)

Używam 14.04 i pliki tam są, a jeśli usunę lub dodam urządzenie, plik / var / lib / bluetooth / (myadapteraddress) / linkkeys zostanie odpowiednio zaktualizowany.

Zrobiłem test na systemie 14.10, dodałem urządzenie BT i utworzono plik / var / lib / bluetooth / (adapteraddress) / linkkeys

Być może używasz nowszej wersji Bluez.

Schemat dla nowych wersji bluez (myślę, że od 5):

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

W dokumentacji przechowywania ustawień dla nowej wersji Bluez znalazłem to:

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

...

W każdym razie wydaje się, że bluez powinien przechowywać pliki w / var / lib / bluetooth

Jeśli użyjesz tego polecenia

bluetoothd --version

dostajesz 4.101?


1
Tak, wersja bluetoothd to 4.101. var/lib/bluetoooth/<adapter address>Folder istnieje, ale nie ma pliku linkkeys, ani podkatalogu. Urządzenie Bluetooth jest sparowane i działa, więc klucze są gdzieś przechowywane, ale na pewno ich tam nie ma. Może wersja Ubuntu przechowuje klucze gdzieś indziej i staram się dowiedzieć gdzie. Używam standardowej instalacji na pulpicie 14.10, parowanie odbywa się za pomocą wskaźnika Bluetooth, nic szczególnego.
ATAKAMA

1
Właśnie przyszło mi do głowy, że niektóre karty Bluetooth mają sprzętowy schowek na klucze. Czy byłoby możliwe, aby Ubuntu bluetoothd przechowywał klucze łącza tylko w pamięci adaptera, a nie w systemie plików? Adapter to: 413c: 8160 Dell Computer Corp. Wireless 365 Bluetooth oparty na Broadcom BCM2046
ATAKAMA

Próbowałeś sparować inne urządzenie, telefon? ... Później spróbuję na innym komputerze z 14.10
J.Serra

Właśnie sparowałem telefon komórkowy, który nigdy nie był sparowany z tym adapterem (ani w Ubuntu, ani w systemie Windows). Plik linkkeys został utworzony. Następnie spróbowałem ponownie sparować mysz, sparowała się, ale jej klucz łącza nie został dodany do pliku. Jak uzyskać bluetoothd, aby odczytał klucz łącza w pliku i nie używał klucza w adapterze (co prawdopodobnie tak robi)?
ATAKAMA

To bardzo ciekawe ... Może jeśli wyeliminujesz urządzenie w systemie Windows, Ubuntu utworzy plik.
J.Serra

0

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

Gdzie {bluetoothaddr} to twój interfejs bluetooth (powinieneś mieć tylko jeden, wygląda jak adres mac)

Format pliku to {remoteaddr} {128-bitowy klucz łącza} {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

Przeczytaj uważnie tekst pytania. Ten plik nie istnieje już w instalacji 14.10. W systemie plików nie ma nigdzie pliku linków. Klucze są przechowywane gdzie indziej. Pytanie brzmi: gdzie.
ATAKAMA

Na moim nowym laptopie, na którym zainstalowałem (bez aktualizacji) 14.10, plik jest nadal taki, jak go opisałem. bluetoothd 4.101. Jakie są wiadomości w syslog, gdy próbujesz sparować nowe urządzenie?
Xavier

Zredagowałem pytanie i dodałem dzienniki, aby porównać wykrywanie i konfigurację połączenia tej myszy z konfiguracją połączenia telefonu komórkowego, którego klucze łącza są zapisane.
ATAKAMA

0

W Debian Jessie i ja zakładamy, że Ubuntu również pozwala ręcznie ustawić PIN, który ma być używany.

  1. Zrób to, co ten post https://askubuntu.com/a/246791/352576 opisuje, aby uzyskać klucz systemu Windows.
  2. twój /var/lib/bluetooth/XX:XX:XX:XX:XX:AA(gdzie XX: ... :AAjest mac adaptera BT twojego komputera) powinien zawierać katalog z mac twojej myszy BT / klawiatury (przedstawię to jako XX: ... :BF, oraz konfigurację i ustawienia plików).
  3. wewnątrz XX: ... BFznajduje się plik infonależący do roota, z uprawnieniami rw do roota. Żadnych innych uprawnień. - treść powinna być:

    [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
    

    Zauważ, że klucz ma długość 16 bajtów.

wklejanie plików linków w tych katalogach nie pomogło mi - chociaż zostawiłem je w dobrym stanie.

Korzystając z naszej strony potwierdzasz, że przeczytałeś(-aś) i rozumiesz nasze zasady używania plików cookie i zasady ochrony prywatności.
Licensed under cc by-sa 3.0 with attribution required.