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
- Find out the wireless interface name:
# ifconfig
- I don't know if this helps, but it doesn't hurt:
# ifconfig wlan0 up
- Just to see if wifi works, scan for available wireless networks:
# iwlist wlan0 scan
- Connect (replace
SSID
with actual id andWIFI_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 thatiwconfig
expects a WEP key, but my wifi runs WPA. - 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 forwpa_supplicant
:network={ ssid="example" proto=WPA key_mgmt=WPA-PSK pairwise=TKIP group=TKIP psk="not so secure passphrase" }
- 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
Killwpa_supplicant
:# kill -9 <wpa_supplicant_pid>
the-9
switch is important, otherwise it comes back alive immediately.
- Start my own
wpa_supplicant
:# wpa_supplicant -c /tmp/wpa_supplicant.conf -iwlan0&
- After successful connection, get client IP address:
# dhclient wlan0