abidibo.net

Just Open Source

Connect to WPA2 wireless network through command line

linux network tips

You can also be interested in:

Lightscribe on ubuntu 14.04 64-bit, what worked for me

There is one rule I learned during my linux experience: If you want to learn things, you've to break things.
Trying to solve problems alone is the best way to increase your linux knowledge.

That said, almost every disaster can be recovered through your command line, so when X crashes, when you have broken your windows manager or display manager, you'll always be able to recover from terminal, BUT you need at least one thing: one active internet connection.

If you can go with a LAN cable ok, there is hopefully no problem, but what if only a WPA protected wlan network is available for you?
Clearly you've to connect to such network through command line in order to use your apt-get or yum or emerge or xxxx commands, so these are the steps you may follow (tested on ubuntu):

  1. Stop the network manager to free the wlan0 interface

    $ sudo /etc/init.d/networkmanager stop
  2. Scan for available wireless networks in order to get the right ESSID

    $ sudo iwlist scanning

    such command returns a list of available wireless networks with many information and in particular the ESSID of each network

  3. Make a config for wpa_supplicant and run it

    $ sudo wpa_passphrase "ESSID" "PASSWORD" > wpaconfig
    $ sudo wpa_supplicant -iwlan0 -cwpaconfig

    Where ESSID and PASSWORD have to be replaced with the network ESSID taken at the step 2 and the network password

  4. Digit [ctrl-z] to run wpa_supplicant in the background

  5. Get assigned an IP

    $ sudo dhclient wlan0
  6. Test your internet connection

    $ ping www.google.com

And now you can recover your system!

Subscribe to abidibo.net!

Special offer!

If you subscribe to this blog within the 7 of february 2016, you'll receive a discount code of 1€ that you can use to buy my first e-book "Your Smartwatch Loves Tasker", available for purchase here on abidibo.net at the price of 3.79€!


If you want to stay up to date with new contents published on this blog, then just enter your email address, and you will receive blog updates! You can set you preferences and decide to receive emails only when articles are posted regarding a precise topic.

I promise, you'll never receive spam or advertising of any kind from this subscription, just content updates.

* indicates required

abidibo.net topics

Comments are welcome!

blog comments powered by Disqus

Your Smartwatch Loves Tasker!

Your Smartwatch Loves Tasker!

Now available for purchase!

Featured