Ubuntu – Connecting to the wireless(WPA) from commandLine

wireless

I want to be able to connect to my WIFI(WPA) network from the command Line.I installed wpasupplicant from the repository and created two files. ONe a script and another a configuration file .

Bash script:

#!/bin/sh
iface=wlan0

#shut down interface
ifconfig $iface down

#set ad-hoc/management of wireless device
iwconfig $iface mode Managed

#enable interface
ifconfig $iface up

#stop any persistent wireless wpa2 sessions
killall wpa_supplicant

#apply WPA/WPA2 personal settings to device
wpa_supplicant -B -Dwext -i $iface -c ./wireless-wpa.conf -dd

#obtain an IP address
dhclient $iface

Conf File:

# config file using WPA/WPA2-PSK Personal key.

ctrl_interface=/var/run/wpa_supplicant

network={
ssid="ssid"
scan_ssid=1
key_mgmt=WPA-PSK
psk="pass"
}

However I keep getting this error:

Initializing interface 'wlan0' conf './wireless-wpa.conf' driver 'wext' ctrl_interface 'N/A' bridge 'N/A'
Configuration file './wireless-wpa.conf' -> '/home/itsy/Desktop/./wireless-wpa.conf'
Reading configuration file '/home/itsy/Desktop/./wireless-wpa.conf'
Failed to read or parse configuration '/home/itsy/Desktop/./wireless-wpa.conf'.
Failed to add interface wlan0
Cancelling scan request
Cancelling authentication timeout

I have even tried substituting wpa_passphrase "myssid" , enter the pass and paste it into the conf file. It still does not work. Could someone please tell me what I am doing wrong?

Best Answer

Apply WPA/WPA2 personal settings to device:

wpa_supplicant -B -Dwext -i $iface -c ./wireless-wpa.conf -dd

Also try apply WPA/WPA2 personal settings to device:

wpa_supplicant -B -Dwext -i $iface -c /etc/wireless-wpa.conf -dd

The directory listing could be off.