How to connect to wireless network from Ubuntu command line (recovery mode) 


September 21, 2014 14:54:22    Last update: September 21, 2014 22:29:56
  1. Find out the wireless interface name:
    # ifconfig

  2. I don't know if this helps, but it doesn't hurt:
    # ifconfig wlan0 up

  3. Just to see if wifi works, scan for available wireless networks:
    # iwlist wlan0 scan

  4. Connect (replace SSID with actual id and WIFI_KEY with actual key):
    # iwconfig wlan0 essid <SSID> key s:<WIFI_KEY>

    This command failed for me with error:
    Error for wireless request "Set Encode" (8B2A) :
    SET failed on device wlan0 ; Invalid argument.

    The reason being that iwconfig expects a WEP key, but my wifi runs WPA.
  5. So, I need to run wpa_supplicant. With no patience to find out how to do it the Ubuntu way, I created a conf file for wpa_supplicant:
    	psk="not so secure passphrase"

  6. But before running my wpa_supplicant, I have to kill the existing one, which didn't seem to to anything.

    Stop network manager:
    # stop network-namager

    Kill wpa_supplicant:
    # kill -9 <wpa_supplicant_pid>

    the -9 switch is important, otherwise it comes back alive immediately.

  7. Start my own wpa_supplicant:
    # wpa_supplicant -c /tmp/wpa_supplicant.conf -iwlan0&

  8. After successful connection, get client IP address:
    # dhclient wlan0

Share |
| Comment  | Tags