how to connect to WPA from command line

First issue the command iwconfig from a shell to see the assigned name of your wireless card .
in this example we will be working with the ath0 .
make sure you have the WPA_supplicant package installed ,visit ,usually it is installed by default in ubuntu.
create a new file called wpa_supplicant.conf ,using nano or your favourite editor and type the following code:
ssid=”your ssid name”
pairwise=CCMP TKIP
psk=” type in your passphrase here the one you use to connect to the AP ”

now save the file somwhere ,mainly /etc/ .or any place you want .
now you need to inform wpa_supplicant to use this file to connect to the wireless AP with the above information .
type in the shell :
wpa_supplicant -D wext -i ath0 -c /etc/wpa_supplicant.conf
the connection process will begin ,you should see at the bottom line something like :
CTRL-EVENT CONNECTED – connection to XX:XX:XX:XX:XX completed .

NOTE : DO NOT CLOSE THIS SHELL .(open up a new shell window complete the down steps ,static or dynamic and then you may close this shell ,some drivers requires this shell window to stay open.)

now i will explain the code above :
wpa_supplicant is the command to run the WPA tool
-D wext , this will tell linux to use the generic wireless wext driver ,it works fine with my WG511T netgear
-i ath0 ,this is the wireless interface
-c wpa_supplicant.conf ,this is to tell wpa_supplicant the location of the conf file ,i kept it in /etc/ so you may change the location to wherever you saved it.

Static ip address
Now it is time to give the atho interface an ip ,netmask ,gw ,dns and so on .
open up a new terminal window
and type the following :
ifconfig ath0 netmask
route add default gw
echo nameserver > /etc/resolv.conf
explnation :
this is if you want a static ip.
the ip’s used above is an example ,use your own ip’s ,netmask ,gw and dns .

DHCP ip address:
if you want to you the DHCP in your Wireless AP or anyother DHCP you already setup then skip the above steps and
just type :
dhclient ath0
both ways static or Dynamic thru DHCP should connect you to your wireless network.

you should be connected by now .
NOTE : this is to connec to WPA based security ONLY ,in order to wep ,it has a different code ,i might be posting it soon .


did you like this article ? is it right ? is it wrong ?
please leave your comments.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: