Linux – bash commands to connect to wifi wpa network in debian

linuxwireless-networking

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!

Best Answer

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"
}
Related Question