Connecting to a wireless network (open and protected) from terminal

5,141

Using wpa_supplicant is sufficient.

Generally only four steps are needed:

  1. Bring interface down using ifdown wlan0

  2. Release IP assignmet using dhclient -r wlan0

  3. Modify the wpa_supplicant configuration file located at /etc/wpa_supplicant/wpa_supplicant.conf

  4. Bring interface up using ifup wlan0

On the second step you have to define wether or not it's an open network or a closed network.

If it's an open network it should contain the keypair key_mgmt with the value NONE, so the configuration file should look something like the following:

network={
   ssid="My Wifi Nework"
   key_mgmt=NONE
#   psk="MyPassPhrase"
}

While if it's a closed network, the key_mgmt is not used and can be commented out, but the psk key is required, as following:

network={
   ssid="My Wifi Nework"
#   key_mgmt=NONE
   psk="MyPassPhrase"
}
Share:
5,141

Related videos on Youtube

vaid
Author by

vaid

Updated on September 18, 2022

Comments

  • vaid
    vaid over 1 year

    I'm trying to connect my RTL8188CU chip to any network on Debian Jessie, but with no success from terminal.

    I need to do this consistently and at any time required.

    I have tried several suggestions from the internet such as ifup wlan0, ifconfig wlan0 up as well as their down opposites.

    I've also tried iwconfig wlan0 essid <wifi cell> and also configured wpa_supplicant configuration file and the /etc/network/interfaces file etc etc but none of the info from the net gives me any reliable results.

    What is going on here?

    Also, connecting to an open network does not seem to work at all, and connecting to a WPA2 protected network seems to only work if I restart my OS.

    Also, ifup wlan0 often gives me the following error

    Error for wireless request "Set Mode" (8B06) : SET failed on device wlan0 ; Operation not permitted. Error for wireless request "Set ESSID" (8B1A) : SET failed on device wlan0 ; Operation not permitted.

    and dhclient often gives me the following error

    No DHCPOFFERS received. No working leases in persistent database - sleeping.

    So to sum it up: connecting to a WPA2 network only works if I configure everything first and THEN reboot. Upon reboot I can disconnect and reconnect to the same network that I'm already connected to, but once I try to change network various errors occur.

    Connecting to open networks does not seem to work at all.

    I have followed the instructions in the following links, and also used some links as reference: https://wiki.debian.org/WiFi/HowToUse#wpa_supplicant https://unix.stackexchange.com/questions/92799/connecting-to-wifi-network-through-command-line Auto connect to any open WiFi with Debian https://wireless.wiki.kernel.org/en/users/documentation/modes How can I connect to a wireless network using only the command line in Linux?

    I've now tried for 2 days straight.

    Does anyone have any clues on why this is happening and guide me in the right direction?