Connecting to WPA networks isn’t the hassle it used to be, it is often very handy to be able to connect without the use of Network Manager. Today I’ll share with you a quick way to get connected to a WPA encrypted network from the shell.
Firstly, make sure you have wpa supplicant installed, it should be on most default installations. Chances are, its already installed if you can or have been able to connect with network manager.
Once you’ve verified it is installed try this one liner (as root):
wpa_passphrase <SSID> <Key> > /etc/wpa_supplicant.conf && `wpa_supplicant | tail -n 1`;
Press Ctrl + Z, then type bg to put it in the background, then you are able to get a DHCP lease with dhclient
What this does is generates the passphrase for your access point and writes it to the file /etc/wpa_supplicant. Once it is written, it then fires up the last line of wpa_supplicant (tail -n 1) which is the example:
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
Of course, you can run this manually if you wish or run with the -B option to skip the manual backgrounding.
Hope this helps!