prudkohliad

Getting Wi-Fi SSID on Mac via bash using Shortcuts


Recent macOS releases restrict direct access to Wi-Fi details like SSID and BSSID for privacy reasons. Commands such as airport are deprecated, and modern tools like wdutil often return redacted values unless run with elevated privileges. Also check out this great post by Dan K. Snelson.

Shortcuts app

The reliable, Apple-supported solution is to use the Shortcuts app.

Shortcuts app in Spotlight
Shortcuts app in Spotlight

Create a new Shortcut and make sure you’re using the “Get Network Details” node with “Wi-Fi” and “Network Name” arguments. Then connect it to another node “Stop and output”.

Get Wi-Fi SSID Shortcut
Get Wi-Fi SSID Shortcut

Getting output in Bash

When you first run the command, MacOS will request permissions.

For some reason the command by itself does not return anything, but when paired with capturing – it will output your SSID:

$ shortcuts run "Get Wi-Fi SSID"
$ output=$(shortcuts run "Get Wi-Fi SSID")
$ echo $output
Anton’s iPhone

You can then use this in your rc file for scripting 👌


Comments

🚧 Please enable JavaScript to use the comments feature

More posts