Command line wifi – Debian

If you want Debian working with wifi on every reboot then you need to configure it. First thing to do is make sure the interface is up using

ip link show

If not then bring it up:

ip link set up wlp2so

NOTE: your network interface name might be different.

One is assuming that you know the SSID of your wifi network but this may be a helpful tool to check that the hardware is working.

iwlist scan | grep ESSID

This should return a list of available networks.

 

For WPA2-PSK networks (which is all I really care about ATM) you need to issue the following command:

$ su -l -c "wpa_passphrase myssid my_very_secret_passphrase > /etc/wpa_supplicant/wpa_supplicant-wlp2s0.conf"

NOTE: the text “wpa_passphrase” is literal  “myssid” need changing to the SSID that you wish to connect to and you also need to change “my_very_secret_passphrase” to your wifi password.

WARNING: The naming of the file is important as if you do not name it correctly then the service will not start.  You must append “wpa_supplicant” with a hyphen ‘-‘ followed by the interface name.

Now if you review the file that the previous command has created then it should look something like:

network={
        ssid="myssid"
        #psk="my_very_secret_passphrase"
        psk=ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
}

Now you can enable wpa_supplicant by issuing

systemctl enable wpa_supplicant@wlp2S0

and now you should be able to start the service.

Next configure /etc/network/interfaces by adding the following 2 lines

allow-hotplug wlp2s0
iface wlp2s0 inet dhcp

Obviously you can set a static ip here in the usual way if you wish.

Finally

ifup wlp2s0

should start then network.

 

ADDITIONAL:

if you want to enable wpa_cli then according to the debian wiki you need to append the following to the wpa_supplicant.conf file

ctrl_interface=/run/wpa_supplicant 
update_config=1

 

https://support.speedify.com/article/826-connect-different-wi-fi-interfaces-to-different-networks-linux

demonstrates how to use wpa_cli to add more networks:

 

This is taken from the speedify website (Currently untested).

“When starting the wpa_cli, you can select the interface you want to configure using the -i argument.

For example:

wpa_cli -i wlan0

It will launch into an interactive mode where you can set options. From here you can confirm that the adapter is scanning and seeing networks by running:

scan

scan_results

That should show a list of the available wireless networks. Then you can add and configure a network, analogous to what you would put in the wpa_supplicant.conf file.

If you’ve already been playing with adding networks in the wpa_supplicant.conf file, you might want to remove them, or you can directly modify them with the wpa_cli tool.

Run

list_networks

to see any existing network configurations. If you already have one in the list, you can modify by using its ID in the command below. Otherwise, add a new network and take notes of its ID.

add_network

set_network <ID> ssid “The WiFi SSID”

set_network <ID> psk “password”

enable_network <ID>

If you have multiple network configurations, you might need to do:

select_network <ID>

If it is a simple network, that should be enough to get it to start connecting to the Wi-Fi network. You can save the configuration by running:

save_config

You can then quit out of the wpa_cli session and start it with the next interface and repeat the above steps.”