Linux Blog

WPA Wireless Networks from Shell

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 1:10 pm on Wednesday, April 20, 2011

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):

1
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

dhclient wlan0

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!





Random Man Pages:
sane-coolscan
i740
tty
ati

4 Comments »

Comment by cypherb0g

April 30, 2011 @ 2:49 am

how can you verify if wpa supplicant is installed ?

Comment by TheLinuxBlog.com

May 1, 2011 @ 4:35 am

which wpa_supplicant or whereis wpa_supplicant. You can also use your package manager but the package name may vary.

Comment by John

May 12, 2011 @ 1:19 am

I use wpa_supplicant on my FreeBSD laptop and it works with my wpa2 network very well indeed, you just need to fill out wpa_supplicant.conf with your SSID and PSK and then you can connect automatically on boot. And then you are all set, but this depends on the distribution whether this will work. But this way is better than using NetworkManager.

Comment by Gauthier

September 11, 2011 @ 2:43 pm

Thanks a lot, it works =)

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>