How To Connect To A WPA Wifi Using Command Lines On Debian

Want to support HowtoForge? Become a subscriber!
 
Submitted by bad_crow (Contact Author) (Forums) on Thu, 2009-07-30 13:13. :: Debian

How To Connect To A WPA Wifi Using Command Lines On Debian

This tutorial will explain how to connect to a WPA (1-2) wireless network without installing any graphical tool.

I assume that your wireless drivers are activated in the kernel and that your card is detected in Linux with the command:

ifconfig -a

Mine is identified by wlan0 but that may change for you.
For Intel users, you may need firmware-iwlwifi from the non-free repository.

For the others let's install wpa support now if you don't have it (you probably have it if you got a graphical interface):

aptitude search wpasupplicant

If there is an "i" in front of wpasupplicant, then it's installed otherwise do:

aptitude install wpasupplicant

Then we will configure a network, so we create and modify the configuration file:

vim /etc/wpa_supplicant.conf

Complete the file to make it look like that (replacing wifi_name and wifi_key by their real values of course). Press "i" to be able to edit.

network={
             ssid="wifi_name"
             psk="wifi_key"
}

Then exit and save (press escape then :wq).

The wifi network is now configured, we must now tell that we want to connect to it using this configuration file.

wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf -Dwext

If your interface isn't named wlan0 then replace wlan0 by the real name of your interface.
We must now request an IP adress.

dhclient wlan0

If everything gone well you now see several lines containing some IP addresses and the command ping should work.
The next time you want to connect juste type the 2 last commands.

This tutorial is now over, I hope you enjoyed it and it was helpful.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Mikkel Meinike-... (not registered) on Mon, 2014-01-13 22:49.

Hi

I just want to thank you. This was just so nice and easy and worked great for me.

 Kind regards

 Mikkel

Submitted by Anonymous (not registered) on Thu, 2013-08-15 22:51.

Thank you so much !!!

You saved me in the middle of a minimal netinstall without desktop environment.

 This tutorial is so simple but yet so effective, it's wonderful.

 

Submitted by thebored1x (not registered) on Sun, 2009-08-16 01:49.

Thank you so much!  All the other How-To's on the internet are hopelessly complicated -- and that's what was keeping my connection from working, extra lines in the .conf file that were doing nasty things

Submitted by Suno Ano (not registered) on Thu, 2009-07-30 15:36.

HI folks,

I wrote a quite verbose article about that subject too

http://sunoano.name/ws/public_xhtml/ggm.html#wifi_and_debian

maybe someone finds it useful ;)