SU_PYROW

Command line WPA

By: SU_PYROW

If you have the commands wpa_passphrase and wpa_supplicant available, then you're good to go. Otherwise, you will need to install wpa_supplicant

Generating the config file

Once you know the SSID and WPA passphrase

$ wpa_passphrase myrouter mypassphrase > wpa.conf

Of course, replace "myrouter" with the SSID of your router, "mypassphrase" with your WPA passphrase, and "wpa.conf" with whatever file you want to store the configuration in. This filename does not have to follow a particular format or have a particular extension.

To avoid typing the passphrase on the command line (so it doesn't get saved in the shell's history), you can specify just the SSID on the command line. wpa_passphrase will wait for you to type in the passphrase followed by enter:

$ wpa_passphrase myrouter > wpa.conf
mypassphrase

You should end up with a file looking like this:

network={
	ssid="myrouter"
	#psk="mypassphrase"
	psk=8ada1f8dbea59704ac379538b4d9191f6a72390581b4cd7a72864cea685b1a7f
}

Getting connected

If your router broadcasts its SSID (they all do by default), you probably want to make sure your wireless card can actually see it: as root:

$ iwlist scan
wpa_supplicant --help

lists the different drivers it has (under "drivers:"). As of 0.5.8, the useful choices are: wext, hostap, madwifi, atmel, ndiswrapper, and ipw (ipw is for old kernels only; >=2.6.13 should use wext). If you don't see a specific match for your card, try wext.

The network device of your card. This is usually eth1 or wlan0, but if you're unsure you can just run iwconfig. It will report "no wireless extensions" for non-wireless devices and will display some data for any wireless devices. The path to the configuration file that you created in the previous step. Now that you have this data, run (as root):

# wpa_supplicant -D[driver] -i[device] -c[/path/to/config]

There are no spaces between the options and parameters. Don't include the brackets as I just added those for clarity. For example:

# wpa_supplicant -Dwext -ieth1 -c/root/wpa.conf

You can also run it in the background by using the -B option so that it doesn't take up your console.

Now you're hopefully associated with the network. To verify run iwconfig and look for "Access Point: XX:XX:XX:XX:XX:XX""

# iwconfig wlan0

This document was last modified on: 472519 12:38:48 UTC