Skip to content

Instantly share code, notes, and snippets.

@maage
Last active October 25, 2022 16:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maage/02a8ddb0cb6513e92559f40938a5d292 to your computer and use it in GitHub Desktop.
Save maage/02a8ddb0cb6513e92559f40938a5d292 to your computer and use it in GitHub Desktop.
wpa_cli with raspberrypi 3 raspbian 9 / stretch
# You can use tab and partial match if unique
# show encoded passphrases
% wpa_passphrase 'SSID1' 'pass1'
% wpa_passphrase 'SSID2' 'pass2'
# Without these this data is saved into history file
% HISTFILESIZE=0
% HISTSIZE=0
# Need to define interface as /run/wpa_supplicant/ has p2p-dev-wlan0 to mess things up
% sudo wpa_cli -i wlan0
# If status is DISCONNECT, then you have device wrong or something wrong with the device.
> status
wpa_state=INACTIVE
...
# Configuration basic setup, change country to be yours
> set update_config 1
> set country FI
> add_network
> add_network
> status
> scan
> scan_results
# Use double quotes
> set_network 0 ssid "SSID1"
# from wpa_passhrase for SSID1, no quotes
> set_network 0 psk ab...
# highest wins
> set_network 0 priority 10
> enable_network 0
> set_network 1 ssid "SSID2
> set_network 1 psk ab...
> set_network 1 priority 1
> enable_network 1
> save_config
# fallback unsecure
> add_network
2
> set_network 2 key_mgmt NONE
OK
> set_network 2 priority -999
OK
> enable_network 2
OK
> save_config
OK
> reconfigure
OK
# To change settings you need to do it this way
> set_network 1 priority 11
OK
> save_config
OK
> reconfigure
OK
# Now disconnects network 0 and connects network 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment