Pair with a Bluetooth device over Terminal

blueutil (available via HomeBrew) is the answer. I just used it following the guidelines in this blog post.

In my case, I had an iMac with macOS Catalina that had no trackpad paired. I was stuck at the "Send Apple Crash Analytics?" screen with no keyboard controls. Using SSH, I connected to the machine and used the following commands to pair and then connect the trackpad without access to the GUI. (First, I had to turn the trackpad into Discoverable mode. The default PIN for Apple pointer devices is 0000.)

% blueutil --inquiry
address: d0-a6-xx-xx-xx-xx, not connected, not favourite, not paired, name: "-", recent access date: -
% blueutil --pair d0-a6-xx-xx-xx-xx
Type pin code (up to 16 characters) for "Cheshire, Josh’s Trackpad" (d0-a6-xx-xx-xx-xx) and press Enter: 0000
% blueutil --connect d0-a6-xx-xx-xx-xx

At that point, the trackpad worked.


The tool blueutil uses private APIs from the IOBluetooth framework to interact with bluetooth devices. You are able to list recent devices using:

blueutil --recent

and connect to a specific device using:

blueutil --connect $device_adress

This seems a little bit "hacky", but you can do this by using an oascript which emulates the GUI-interactions needed for connecting: https://stackoverflow.com/a/23018886/5269642

I couldn't really find any documented API's for bluetooth unfortunately, the oascript-approach was the best I could find/think of so far.