Support key sync from Windows to MacOS
See original GitHub issueI just did this manually and it was pretty straightforward.
From a paired device in Windows 10 (the Bose 700s, which interestingly support LE but were not paired by LE), I exported the link key data, changed the endianness to MacOS, then replaced this in the Mojave /private/var/root/Library/Preferences/com.apple.bluetoothd.plist
(I used a hex editor to find and replace the existing paired key with Windows’).
The only gotcha was that I had to not only disable Bluetooth before modifying the plist
file, but also perform a system reboot before starting Bluetooth again. Otherwise, something was reverting the key change to the plist
file. I tried to see if I could figure out which specific service was doing this but didn’t have any luck.
I appreciate that perhaps replacing the key on Windows is easier than the above but wanted to share that it is indeed possible nevertheless.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14
Top GitHub Comments
Ok here it is without sed maybe it will be better `cd “$(dirname “$0”)” rm /tmp/temp.plist
/usr/libexec/PlistBuddy -c “Add LinkKeys dict” /tmp/temp.plist input=BTKeys.reg while IFS= read -r line do if [[ “$line” == ‘HKEY_LOCAL_MACHINE’ ]] then t=$(printf “%s” ${line} | awk -F \ ‘{print $8}’ | tr -d ‘]’) echo echo “BT:”$t /usr/libexec/PlistBuddy -c “Add LinkKeys:$t dict” /tmp/temp.plist fi
if [[ “$line” == ‘=hex’ ]] then key=$(printf “%s” ${line} | awk -F ‘=’ ‘{print $1}’ | tr -d ‘"’) value=$(printf “%s” ${line} | awk -F ‘:’ ‘{print $2}’ | tr -d ‘,’) echo $key $value printf $value | xxd -r -p > /tmp/bin /usr/libexec/PlistBuddy -c “Import LinkKeys:$t:$key /tmp/bin” /tmp/temp.plist plutil -convert binary1 /tmp/temp.plist fi
done < “$input” echo mv /tmp/temp.plist ./blued.plist `
and one more script for those who has a lot of different macOSes installed `if [[ $EUID -ne 0 ]]; then echo “This script must be run as root” exit 1 fi
if [[ -f “/private/var/root/Library/Preferences/com.apple.bluetoothd.plist” ]] then source=“/private/var/root/Library/Preferences/com.apple.bluetoothd.plist” fi
if [[ -f “/private/var/root/Library/Preferences/blued.plist” ]] then source=“/private/var/root/Library/Preferences/blued.plist” fi
if [[ $source ]] then defaults read $source else echo “File not found” exit fi
for s in /Volumes/*/private/var/root/Library/Preferences do
if [[ -f “$s/com.apple.bluetoothd.plist” ]] then target=“$s/com.apple.bluetoothd.plist” fi
if [[ -f “$s/blued.plist” ]] then target=“$s/blued.plist” fi
cp -v “${source}” “${target}”
done`