How to get list of available wireless networks without being root
You could (or do?) probably use wpa_supplicant
; using its ctrl_interface
configuration key, you can allow non-root users (e.g. those with group wheel
) access via wpa_cli
(i.e. /sbin/wpa_cli scan_results
[1])
# allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
There's also a command-line switch to wpa_suppliant
,
-u Enabled DBus control interface. If enabled, interface defini‐
tions may be omitted.
giving you a DBus interface and thus another possibility for non-root access (I think NetworkManager uses this interface).
[1] Once connected, this only shows the wireless LAN you are connected to...I don't know if this is any different with NetworkManager.
Related videos on Youtube
Carlito
Updated on September 18, 2022Comments
-
Carlito over 1 year
I would like to get a list of all the wireless networks.
iwlist wlan0 scan | grep ESSID
This will only show me the wireless network I am currently connected to. When I run the command as root, it shows me all the available networks. If I run the command without sudo quickly after this, all the networks will show up, but after a while they are all gone except the network I am currently connected to.
Is there a way to get all the available networks when I am not root?
-
Carlito almost 12 yearsThank you for your answer. Adding "GROUP=wheel" and calling
wpa_cli scan
andwpa_cli scan_results
do the trick for me. Do you know if the same change (allowing the wheel group to execute) is possible with iwlist? -
sr_ almost 12 yearsNo idea, sorry.