I have multiple wifi network ssid's saved in my etc/wpa_supplicant/wpa_supplicant.conf like shown below, can we delete a specific network from this wpa_supplicant.conf
Ex: in the below networks can a delete the network myssid1 through a shell script which i can then execute through node.js server
network={
ssid="myssid1"
scan_ssid=0
proto=WPA
key_mgmt=WPA-PSK
psk=5f55a9b869e9ab6d03839cae23c7243accc0ac0a12079d358328bf73ad2e0ebe
}
network={
ssid="myssid2"
scan_ssid=0
proto=WPA
key_mgmt=WPA-PSK
psk=d89660510d06bbf7691f5296daae36872d697a88876c53db7de91aa85df4f68b
}
network={
ssid="myssid3"
scan_ssid=0
proto=WPA
key_mgmt=WPA-PSK
psk=d635b33481a13b28a67e8964f58343cb19bc8c85c67cc56ee9bfe0c302914a5f
}
You can write it you're self. Some very ugly Quick-n-Dirty Code would be for example:
i was able to get it done with the below script:
The temp var is needed because this is the easiest way I found to actually make awk write to he file its processing. To see the effect of changing wpa_supplicant.conf, do
Some references:
using
wpa_cli
you can do this:1:
where
0
is the network_id you get after runningwpa_cli add_network
. It will remove the network and disconnect any interface using it.Note that the
network id
is not the order of the network in the file. you can get configured network usingwpa_cli list_networks
2:
This will persist the changes and the corresponding network block will be removed from
etc/wpa_supplicant/wpa_supplicant.conf