User Tools

Site Tools


howto:wpawithspaces

Using WPA and WPA2 with spaces in the SSID and/or passkey on the default Xandros installation

The Network GUI on the default Xandros installation does not correctly parse spaces in a WPA/WPA2 SSID and passkey, which hampers connectivity if the access point requires one or more spaces.

This page is intended to show you how to configure your Eee PC to use WPA and WPA2, with spaces in the SSID and passkey, without downloading any additional tools. The steps in this document have been tested on a PC701 4G (BIOS version 0801), freshly factory-restored from the supplied DVD, connecting to a Linksys WRT54GL running dd-wrt with WPA2/AES enabled. The information presented here has been collated from snippets posted in numerous places on the wiki and forum.

I have learned two methods of performing this: the quick method, and the slightly longer method.

The quick method

  • Create a wireless connection using the Network application. When prompted for the SSID, type the proper SSID, including any spaces. Set encryption to WPA, and enter a bogus Key, without spaces (you'll be entering the proper key later on). Do not select the option Start this connection when finished.
  • Press Ctrl-Alt-T to open a command shell.
  • Type the following command:
    sudo nano /etc/network/interfaces
  • Find the line which begins wireless-key s: and replace the bogus passphrase with your chosen one, including any spaces. Do not put quotation marks around it.
  • Press Ctrl-O followed by Return to save the file. Then press Ctrl-X to exit the editor.
  • Now type the following command:
    sudo kwrite /etc/network/if-pre-up.d/0001xandros-wireless-tools
  • Find the 3 lines starting with if [ -n `echo $IF_WIRELESS_KEY | grep ^s:` ]; then … ending with a fi line (fi ends if, get it?), and replace them with IF_WIRELESS_KEY=“${IF_WIRELESS_KEY#s:}” . That's bash's built in way to say cut anything matching “s:” from the head. The “s:” prefix must be used in another script as a sigil about this being a string, not hex, key.
  • In the same file (/etc/network/if-pre-up.d/0001xandros-wireless-tools), find the line which reads /usr/sbin/xandros-wpa-config $WPA $IF_WIRELESS_KEY “$IF_WIRELESS_ESSID” (it's line 312 on my machine; yours may differ) and put quotation marks around $IF_WIRELESS_KEY. The line should now read /usr/sbin/xandros-wpa-config $WPA “$IF_WIRELESS_KEY” “$IF_WIRELESS_ESSID”.
  • Press Ctrl-S to save the file, followed by Ctrl-Q to exit the editor.
  • Type the following command:
    sudo kwrite /usr/sbin/xandros-wpa-config
  • Find the line which reads PSKOUT=`/usr/sbin/wpa_passphrase “$ESSID” $WPA_KEY` (it's line 50 on my machine; yours may differ) and put quotation marks around $WPA_KEY. The line should now read PSKOUT=`/usr/sbin/wpa_passphrase “$ESSID” “$WPA_KEY”`.
  • Press Ctrl-S to save the file, followed by Ctrl-Q to exit the editor.
  • Go back to the Network application, select your wireless connection, and click on Connection → Connect. If all is well, you should have a working connection to your router and thus the Internet.

The slightly longer method

  • Create a wireless connection using the Network application. When prompted for the SSID, type the proper SSID, including any spaces. Set encryption to WPA, and enter a bogus Key, without spaces (you'll be entering the proper key later on).
  • Now select the connection you've just created, and click on Connection → Connect. The connection will fail (the passkey is wrong, after all), but that's not important. What is important is the dynamically-created configuration file which is only present during a connection attempt…
  • While the network application is trying to connect to your router, press Ctrl-Alt-T to open a command shell.
  • You should be in your home directory (/home/user for most people). If not, type the following command to change to your home directory:
    cd
  • Type the following command:
    cp /etc/wpa_supplicant.conf.ath0 wpa_supplicant.conf_MINE
  • Type the following command:
    nano wpa_supplicant.conf_MINE
  • You should see something like this:
    ctrl_interface=/var/tmp/wpa_supplicant
    network={
        ssid="My SSID"
        key_mgmt=WPA-PSK
        psk=1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
    }
  • In the example above, replace “My SSID” with the SSID of your router. Make sure it's enclosed in quotation marks.
  • The other magic bit is the 64 characters after psk=. They're the encrypted form of the bogus passkey you typed earlier. You're going to replace them with the encrypted form of your real passkey. There's a little program on your Eee which can calculate the proper PSK, or there's a handy online tool you can use to create the encrypted passkey: http://www.wireshark.org/tools/wpa-psk.html
  • Carry out one of the following two instructions:
    1. Open a command shell (Ctrl-Alt-T) and type the following command, replacing the SSID and passphrase with your own:
      sudo wpa_passphrase "My SSID" "My passphrase including spaces"
    2. Go to the Wireshark page and enter your SSID and desired passkey, and click on Generate PSK. Like the page says, wait a while. Go make a cup of tea. Eventually you'll see a 64-character string appear to the right of PSK.
  • Go back to your text editor window, and replace the 64-character string after psk= with the real PSK you just obtained either from the Wireshark page or from wpa_passphrase. Type very carefully. One single wrong character will cause the connection to fail.
  • Press Ctrl-O followed by Return to save the file. Then press Ctrl-X to exit the editor.
  • Go back to the Network application, select your wireless connection, and click on Connection → Disconnect.
  • Now go back to your command shell window, and type the following command:
    sudo cp wpa_supplicant.conf_MINE /etc
  • Type the following command:
    cd /etc/network
  • Now type the following:
    sudo nano interfaces
  • See the line which begins wireless-essid and is followed by your router's SSID in quotation marks? Remove the quotation marks. If the line reads wireless-essid “My SSID” it should become wireless-essid My SSID. Ignore the following line, the one which contains the bogus passkey you entered earlier.
  • Go up a couple of lines, to the line which reads up ifconfig $IFACE up. You need to insert the following two lines immediately before that line:
    up cp /etc/wpa_supplicant.conf_MINE /etc/wpa_supplicant.conf.ath0
    up wpa_cli -p /var/tmp/wpa_supplicant reconfigure
  • As before, press Ctrl-O followed by Return to save the file, then Ctrl-X to exit the editor.
  • Go back to the Network application, select your wireless connection, and click on Connection → Connect. If all is well, you should have a working connection to your router and thus the Internet.

Afterword

If this doesn't work for you, go through each step carefully. Make sure your typing is completely accurate, especially where the encrypted passkey is concerned. I'm not a Linux expert; I just pieced together various bits of information to get this working for me. I hope it's useful for you, too.

howto/wpawithspaces.txt · Last modified: 2008/08/01 06:09 by pen_sq