Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to connect to my router but having no luck. I'm just missing some simple probably one line of code that I cant find anywhere.

If I write iwlist wlan0 scan, it shows over 20+ networks that I can connect to so my wireless card is definitely set up correctly. For example, I want to connect to a WPA network called "herroprease" with password "wearechinesepeople", so I type

iwconfig wlan0 essid herroprease key s:wearechinesepeople
dhclient wlan0

However, when I ping 192.168.1.1 (my router) it says that it can't connect. I've heard that to connect to WPA networks there are extra commands you have to give to bash with wpa_supplicant. Is that so? I'm looking for the simplest easy to understand code to get online. Thanks for any help!

share|improve this question

migrated from stackoverflow.com Dec 19 '11 at 14:58

This question came from our site for professional and enthusiast programmers.

    
+1 but voted to move to superuser – sehe Dec 19 '11 at 14:27
    
Maybe you can try wicd. Using the command line to setup wifi on Linux is always difficult for me. – cyfdecyf Dec 19 '11 at 14:36
    
im determined to learn command line! :) im running debian squeeze in text only mode cos i want to learn how to do everything by command line. Wifi connection is proving tough tho >.< – james Dec 19 '11 at 14:38
    
Then refer to Debian's wiki, first configure it by modifying /etc/network/interfaces. If that succeeds, study the differences of the iwconfig output before and after. – cyfdecyf Dec 19 '11 at 14:55

For the benefit of all who read this and need help. my solution was wpa_supplicant since the network I was trying to connect to was WPA2.

My code was as follows:

iwconfig wlan0 essid herroprease key s:wearechinesepeople
wpa_supplicant -Dwext -iwlan0 -B -c/wpa_supplicant/wpa_supplicant.conf
dhclient

your wpa_supplicant.conf file simply needs to contain

network={
ssid="herroprease"
psk="wearechinesepeople"
}
share|improve this answer

As cyfdecyf pointed out in comments, Debian's Wiki contains the information you're looking for, at least for setting up a persistant connection in the /etc/network/interfaces file.

share|improve this answer

You must log in to answer this question.