6

Say I have connected with wpa_cli to a network mynetwork:

# wpa_cli 
>add_network
>set_network 0 ssid "mynetwork"
>set_network 0 psk "SupahSecretPassphrase"
>enable_network 0
>reconnect

How to export this network to a wpa_supplicant configuration file, that is a file containing:

network={
               ssid="mynetwork"
               psk="SupahSecretPassphrase"
          }

If there is no standard way, I guess I would have to recall ~/.wpa_cli_history


PS:

I tried save_config but I always have a FAIL result:

>  save_config
FAIL
GAD3R
  • 63,407
  • 31
  • 131
  • 192

1 Answers1

4

You should add update_config=1 to your configuration file , it will give the rights to update it.

there is an example :

edit the /etc/wpa_supplicant/wpa_supplicant_example.conf , add the following lines:

ctrl_interface=/run/wpa_supplicant
update_config=1

Run wpa_passphrase command to export your configuration to wpa_supplicant_example.conf

wpa_passphrase Your_ssid Your_passphrase >> /etc/wpa_supplicant/wpa_supplicant_example.conf

Save then connect through wpa_cli.

GAD3R
  • 63,407
  • 31
  • 131
  • 192
  • Honestly I still get the FAIL error when trying to `save_config`, following these steps didn't work to me. – another Feb 10 '18 at 19:18
  • @roizpi Did you have NetworkManger installed? Did you have a wired connection available to reinstall it later if something went wrong ? If YES remove it. – GAD3R Feb 10 '18 at 19:20
  • I haven't networkmanager installed. I have the wired connection yes, and wlan1 seems to have access point associated, but when disconecting the wire, I can't find any host associated with that machine. – another Feb 10 '18 at 19:32
  • @roizpi Check the status `wpa_cli status` disconnect `wpa_cli disconnect` then try to reconnect. Remove the RJ45 first. – GAD3R Feb 10 '18 at 20:57
  • 1
    I made the network work by using your steps, and making a proper configuration of `/etc/network/interfaces`. Thank you. – another Feb 10 '18 at 21:05