Wednesday, 22 June 2011

Connect to a WPA/WPA2 Secured network in Linux

A combination of wpa_supplicant and wpa_passphrase will do the trick.

First, you need to install the relevant software. You need to have a wired connection at this point, otherwise this wont work.
sudo apt-get install wireless-tools wpasupplicant
Run iwlist scanning, and check your card can see the wireless network in question If it can, run:
wpa_passphrase [your-wireless-network-name] > wpa.conf
The prompt will wait for you to enter a passphrase. Do this and hit enter.
Run wpa_supplicant. Replace wext with the correct wireless driver (which is probably wext, but run wpa_supplicant --help to check) and wlan0 with your wireless interface
wpa_supplicant -Dwext -iwlan0 -c/root/wpa.conf
If that works, you should see text to the effect of “successfully associated”. If not, try again with a different driver, make sure your passphrase is correct, and make sure your wireless interface is working properly.
Hit Ctrl+c, then the up arrow, then add a -B (for background) onto the end of the last command, thus:
wpa_supplicant -Dwext -iwlan0 -c/root/wpa.conf -B
Run dhclient -r to release any DHCP leases you have.
Run dhclient wlan0 to get a new IP address. Substitute wlan0 for your wireless interface, of course.
You should now be connected.

Possibly Related Posts

No comments:

Post a Comment