How to use wpa_supplicant to connect to a wireless network

Introduction

There are various ways to connect to a network e.g. using GUI. A GUI lists all the available networks/ SSIDs and we just have to click, enter password(if the connection is secured) and done. The other ways to connect include NetworkManager(a daemon), nmcli(a cli to control NetworkManager), wpa_supplicant(a relatively low level tool).

wpa_supplicant is a cross platform free software implementation of an IEEE 802.11i supplicant. A supplicant is simply an entity at one end of a LAN. The other end of the LAN has an authenticator that authenticates a connection to it.

To use wpa_supplicant, we need to install wpa_supplicant(e.g. for arch linux, pacman -S wpa_supplicant) which installs two more utilities with it i.e. wpa_passphrase and wpa_cli. wpa_cli is the frontend tool of wpa_supplicant while as wpa_passphrase is used to create a configuration file which contains the network details e.g. the password.

Connecting to a network

Before following the steps below, make sure your network interface is up.
sudo ip link
Search for UP in the output corresponding to your network interface(e.g. wlan0).

  • Scan SSIDs/ Networks:
    iw scan wlan0

    Replace wlan0 with your network interface(use ip link to find yours). Note down the SSID name from the above command.
    TIP: iw scan wlan0 | grep SSID will return only SSIDs only which is what we require here.
  • Create passphrase configuration:
    wpa_passphrase myssid | sudo tee /etc/wpa_supplicant.conf, write the SSID password and press enter.

    Replace myssid with the SSID that you want to connect to.
    This will create a file /etc/wpa_supplicant.conf. We will use this file in our wpa_supplicant command to connect to our network. sudo is required with tee command because the file is being created in root owned directory. We can however create this file in any directory. tee simply puts the output of wpa_supplicant in the given.conf file.
  • Start wpa_supplicant daemon:
    sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf

    This says that start wpa_supplicant in the background(B flag) using wlan0 network interface and /etc/wpa_supplicant.conf as the configuration file. With an extra D flag, we can set the driver to be used e.g. sudo wpa_supplicant -B -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf. This will use nl80211 driver rather than the default being picked.
    At this point, you are connected but no ip address has been assigned. Use iw wlan0 link to confirm
  • Obtain an ip address:
    sudo dhclient wlan0.
    You are now connected to the network. Use ping command to confirm.

58 thoughts on “How to use wpa_supplicant to connect to a wireless network

  1. Hi, my name is Belinda from TopDataList.com

    We are ceasing operations on TopDataList.com and have made our leads available at a discounted price.

    Visit us on TopDataList.com
    Regards,
    Belinda

  2. Hi.

    Are you looking for more clients? We provide bulletproof smtp servers to companies so they can send out cold emails without getting blocked.

    You can contact me on WhatsApp +27 72 280 1952 if you are interested or reply to this email.

  3. Hello.

    We provide bulletproof SMTP servers for you to send cold emails without getting blocked.

    We charge $500/year for servers that can send 300k/day.

    You can contact me on whatsapp at +27 72 280 1952 or respond to this email if you are interested.

  4. This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

  5. Hello, did you know that there are 241,120 internet directories in the world.

    These websites are what drive traffic to YOUR business.

    Want more traffic? Want more Sales? We can help – today.

    Your website stackpointer.dev is listed in only 69 of these directories.

    Get more traffic for your Global audience.

    Our automated system adds your website to all of the directories.

    You can find it here: getlisted.directory/stackpointer.dev

    Act today, and we will expedite your listings and waive the processing charge!

  6. I feel that is one of the such a lot significant info for me. And i am happy studying your article. But wanna observation on some common issues, The web site taste is ideal, the articles is in reality great. Good process, cheers

  7. Convert stackpointer.dev to an app with one click!

    80% of users browse websites from their phones.

    Have the App send out push notifications without any extra marketing costs!

    MakeMySiteMobile.com

  8. Hello, did you know that there are 241,120 internet directories in the world.

    These websites are what drive traffic to YOUR business.

    Want more traffic? Want more Sales? We can help – today.

    Your website stackpointer.dev is listed in only 69 of these directories.

    Get more traffic for your Global audience.

    Our automated system adds your website to all of the directories.

    You can find it here: getlisted.directory/stackpointer.dev

    Act today, and we will expedite your listings and waive the processing charge!

    We have a special going on. Use “FRIENDS” on checkout for a 50% discount valid today.

  9. Hello, did you know that there are 241,120 internet directories in the world.

    These websites are what drive traffic to YOUR business.

    Want more traffic? Want more Sales? We can help – today.

    Your website stackpointer.dev is listed in only 69 of these directories.

    Get more traffic for your Global audience.

    Our automated system adds your website to all of the directories.

    You can find it here: getlisted.directory/stackpointer.dev

    Act today, and we will expedite your listings and waive the processing charge!

    We have a special going on. Use “FRIENDS” on checkout for a 50% discount valid today.

  10. Good job on the new site! Now go ahead and submit it to our free directory here bit.ly/submit_site_4lSEZtY470R0

  11. Give your new site a boost, submit your site now to our free directory and start getting more clients bit.ly/submit_site_l1aa2sZgZ1G6

  12. Sweeet blog! I found itt while searching on Yahooo News. Do you hav anny tiips on how tto geet lised inn Yahhoo News?
    I’ve beeen trying for a while buut I nevwr seem too geet there!
    Thabk you

  13. The OpusMining is engaged in cloud mining provision while using the technology, developed by the experts in IT and cryptocurrencies field. The main product idea is effective disparate computing resources appliance. We tend to unite investors, including newcomers, on a single platform together. Our customers’ trust is based on obvious evidence: they honestly get their income every day.

Leave a Reply to Trx Mining Cancel reply

Your email address will not be published.