Linux Commands Examples

A great documentation place for Linux commands

wpa_supplicant

Wi-Fi Protected Access client and IEEE 802.1X supplicant


see also : wpa_cli - wpa_passphrase

Synopsis

wpa_supplicant [ -BddfhKLqqtuvW ] [ -iifname ] [ -cconfig file ] [ -Ddriver ] [ -PPID_file ] [ -foutput file ]


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

1
source
            
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
0

In most common cases, wpa_supplicant is started with:

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

This makes the process fork into background.

The easiest way to debug problems, and to get debug log for bug reports, is to start wpa_supplicant on foreground with debugging enabled:

wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d

If the specific driver wrapper is not known beforehand, it is possible to specify multiple comma separated driver wrappers on the command line. wpa_supplicant will use the first driver wrapper that is able to initialize the interface.

wpa_supplicant -Dnl80211,wext -c/etc/wpa_supplicant.conf -iwlan0

wpa_supplicant can control multiple interfaces (radios) either by running one process for each interface separately or by running just one process and list of options at command line. Each interface is separated with -N argument. As an example, following command would start wpa_supplicant for two interfaces:

wpa_supplicant \

-c wpa1.conf -i wlan0 -D hostap -N \

-c wpa2.conf -i ath0 -D madwifi


0
source

How to connect to a WiFi from command line under Ubuntu without .conf file?

You want a cli command that manages your wpa_suplicant-config? Have you tried ifup, ifdown and ifcfg? They handle connection scripts and work for wifi too but may need some tinkering with.

0
source

While using ad-hoc networking, how to I force nodes to use the same cell IDs (bssid)?

I'm trying to connect some Raspberry Pi via ad-hoc mesh network. And encountered same problem, different cell, or known as "Cell Splitting".

After days of search, I found this great post:

http://tiebing.blogspot.com/2009/12/ad-hoc-cell-splitting-re-post-original.html

So I solved this problem and here is my script:

    $IFC "$IFACE" down
    $IWC "$IFACE" mode managed
    $IWC "$IFACE" power off
    $IWC "$IFACE" mode ad-hoc channel 10 rts 250 frag 256
    $IWC "$IFACE" essid whateveryouwant
    $IWC "$IFACE" key off
    $IWC "$IFACE" ap 11:22:33:44:55:66
    $IFC "$IFACE" up
    $IFC "$IFACE" 10.10.10.10/24 up

The command "sudo iwconfig ath0 ap 11:22:33:44:55:66" forces my ralink5370 into specified cell-id.

Hope this helps.

0
source

How should I troubleshoot a problematic wireless connection on Linux?

According to this thread the dongle you bought is not natively supported and requires the ath9k drivers. Though, that might be outdated information by now.

Have a look at the ath9k graphical installer. I think should help.

If that doesn't help please give us the output of nm-tool.

0
source

wpa_supplicant : Blacklist wireless networks by BSSID

Wire up this code to a command-line option.

I don't think there is any built-in setting to take care of this but basically you should be able to go to main.c, and wire up a command line option like --blacklist=00:11:22:33:44;55:66:77:88:99 (the BSSIDs separated by semicolons).

To make it persistent you'd have to store it in wpa_supplicant.conf but it's easy enough to replace wpa_supplicant with a wrapper that adds your --blacklist parameter.

If you manage to cook up a patch and it seems relatively bug-free and generally useful, you may want to submit it upstream.

NOTE: Intermediate knowledge of the C programming language is required to complete this task. If you don't have the knowledge, you may get better results by asking at another site like StackOverflow.

0
source

wpa_supplicant for dual WLAN

You create two separate wpa_supplicant.conf files, one for each interface. Then you specify which conf file goes with which interface when you invoke wpa_supplicant. You use the -N option to show that you want to start describing a new interface.

This example comes right out of the wpa_supplicant(8) man page:

wpa_supplicant \
    -c wpa1.conf -i wlan0 -D hostap -N \
    -c wpa2.conf -i ath0 -D madwifi
0
source

Wpa supplicant suddenly stopped working

Schoolboy error: it turned out that I incidentally installed network-manager on the system and it interfered with my manual wpa_supplicant configuration. After removing it everything is back to normal!

0
source

Addressing a host from both internal and external networks

I suppose that you have SOHO hardware router and cannot, for example, tweak iptables setup on it. In that case, I think the easiest way is to set up a simple proxying DNS server on SVN machine (like pdnsd, set it as a DNS server in router config, then get a dynamic DNS (probably you are already using one) and map that domain to your local IP address in your local DNS.

So when SVN is accessed from outside, your laptop resolves the domain to external address and your router forwards the connection; when from inside, the same domain resolves to local IP and direct connection is estabilished. Moreover, that allows you to use single SSL certificate valid for that domain if you want.

0
source

Error: "failed to connect to wpa_supplicant - wpa_ctrl_open no such file or directory" using netcfg with wpa_supplicant

You are referencing /etc/wpa_supplicant.conf incorrectly, due to an outdated wiki entry.

The configuration file for the wpa_supplicant package was moved to the sub-directory /etc/wpa_supplicant/ a few months back.

Specify the file as /etc/wpa_supplicant/wpa_supplicant.conf in your /etc/network.d/wpa_suppl file.

Package Contents:

etc/
etc/wpa_supplicant/
etc/dbus-1/
etc/dbus-1/system.d/
etc/dbus-1/system.d/wpa_supplicant.conf
etc/wpa_supplicant/wpa_supplicant.conf
<snip>
0
source

Where can I find a full list of wpa-* options for the interfaces file?

/etc/wpa_supplicant/functions.sh is what you're interested in. Look at the conf_wpa_supplicant function. In there, look for all of the calls to the wpa_cli_do function; you're interested in the 4th or 5th argument (if set_argument is the 3rd arg, then you want the 5th) to each call.

Here's a list I extracted quickly from the file with some shell magic:

wpa-ap-scan
wpa-preauthenticate
wpa-psk
wpa-wep-key[0..3]
wpa-altsubject-match
wpa-altsubject-match2
wpa-anonymous-identity
wpa-auth-alg
wpa-bssid
wpa-ca-cert
wpa-ca-cert2
wpa-ca-path
wpa-ca-path2
wpa-client-cert
wpa-client-cert2
wpa-dh-file
wpa-dh-file2
wpa-eap
wpa-eap-methods
wpa-eapol-flags
wpa-eappsk
wpa-engine
wpa-engine-id
wpa-fragment-size
wpa-freq-list
wpa-frequency
wpa-group
wpa-identity
wpa-id-str
wpa-key-id
wpa-key-mgmt
wpa-mode
wpa-nai
wpa-pac-file
wpa-pairwise
wpa-password
wpa-pcsc
wpa-peerkey
wpa-phase1
wpa-phase2
wpa-pin
wpa-priority
wpa-private-key
wpa-private-key2
wpa-private-key-passwd
wpa-private-key-passwd2
wpa-proactive-key-caching
wpa-proto
wpa-scan-freq
wpa-scan-ssid
wpa-ssid
wpa-subject-match
wpa-subject-match2
wpa-wep-tx-keyidx
0
source

Where is wpa_supplicant started and how do you change config file (on Debian)?

The scripts responsible for configuring wireless network interfaces at boot are located in

  /etc/network/{if-pre-up.d,ip-up.d,if-down.d,if-post-down.d} 

Each of these directories contains a wpasupplicant file, which is just a symbolic link to /etc/wpasupplicant/ifupdown.sh, a script that states, in its header:

  #####################################################################
  ## Purpose
  # This file is executed by ifupdown in pre-up, post-up, pre-down and
  # post-down phases of network interface configuration. It allows
  # ifup(8), and ifdown(8) to manage wpa_supplicant(8) and wpa_cli(8)
  # processes running in daemon mode.
  #
  # /etc/wpa_supplicant/functions.sh is sourced by this file.

There is no reference to wpa_supplicant per se in this file, but the reference is in functions.sh, the file sourced by wpasupplicant. It contains the following lines:

  WPA_SUP_BIN="/sbin/wpa_supplicant"
  ....
  start-stop-daemon --start --oknodo $DAEMON_VERBOSITY \
  --name $WPA_SUP_PNAME --startas $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE \
   -- $WPA_SUP_OPTIONS $WPA_SUP_CONF
  ....
  start-stop-daemon --stop --oknodo $DAEMON_VERBOSITY \
  --exec $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE

These are the two calls you wish to modify.

0
source

wpa_supplicant passphrase, can it be normal password?

It does not have to be configured with wpa_passphrase. In fact, the very first example of the Manpage for the wpa_supplicant.conf file is:

   QUICK EXAMPLES

   1. WPA-Personal (PSK) as home network and WPA-Enterprise with EAP-TLS as work network.

      # allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
      #
      # home network; allow all valid ciphers
      network={
           ssid="home"
           scan_ssid=1
           key_mgmt=WPA-PSK
           psk="very secret passphrase"
      }
      #

You see that in this case you are free to add your password in clear text to the file: the " " means exactly that, the password is in clear text, and that it will have to be hashed for it to become a proper PSK.

wpa_passphrase generates that PSK from the ASCII password (and from the SSID), a step which is automatically performed by wpa_supplicant when presented with the clear-text password between apices.

I would also like to stress that there is no extra security involved in storing your PSK in clear text or in hashed form, on your pc. Any half competent attacker grabbing hold of your PSK will be able t use it to connect to your wifi system, without even bothering trying to re-construct the original clear-text form of the password, an impossible and useless task.

architecture

The wpa_supplicant system consists of the following components:
wpa_supplicant.conf

the configuration file describing all networks that the user wants the computer to connect to.

wpa_supplicant

the program that directly interacts with the network interface.

wpa_cli

the client program that provides a high-level interface to the functionality of the daemon.

wpa_passphrase

a utility needed to construct wpa_supplicant.conf files that include encrypted passwords.

available drivers

A summary of available driver backends is below. Support for each of the driver backends is chosen at wpa_supplicant compile time. For a list of supported driver backends that may be used with the -D option on your system, refer to the help output of wpa_supplicant (wpa_supplicant -h).

hostap

(default) Host AP driver (Intersil Prism2/2.5/3). (this can also be used with Linuxant DriverLoader).

hermes

Agere Systems Inc. driver (Hermes-I/Hermes-II).

madwifi

MADWIFI 802.11 support (Atheros, etc.).

wext

Linux wireless extensions (generic).

broadcom

Broadcom wl.o driver.

wired

wpa_supplicant wired Ethernet driver

roboswitch

wpa_supplicant Broadcom switch driver

bsd

BSD 802.11 support (Atheros, etc.).

ndis

Windows NDIS driver.

command line options

Most command line options have global scope. Some are given per interface, and are only valid if at least one -i option is specified, otherwise they’re ignored. Option groups for different interfaces must be separated by -N option.
-b br_ifname

Optional bridge interface name. (Per interface)

-B

Run daemon in the background.

-c filename

Path to configuration file. (Per interface)

-C ctrl_interface

Path to ctrl_interface socket (Per interface. Only used if -c is not).

-i ifname

Interface to listen on. Multiple instances of this option can be present, one per interface, separated by -N option (see below).

-d

Increase debugging verbosity (-dd even more).

-D driver

Driver to use (can be multiple drivers: nl80211,wext). (Per interface, see the available options below.)

-f output file

Log output to specified file instead of stdout.

-g global ctrl_interface

Path to global ctrl_interface socket. If specified, interface definitions may be omitted.

-K

Include keys (passwords, etc.) in debug output.

-t

Include timestamp in debug messages.

-h

Help. Show a usage message.

-L

Show license (GPL and BSD).

-p

Driver parameters. (Per interface)

-P PID_file

Path to PID file.

-q

Decrease debugging verbosity (-qq even less).

-u

Enabled DBus control interface. If enabled, interface definitions may be omitted.

-v

Show version.

-W

Wait for a control interface monitor before starting.

-N

Start describing new interface.

interface to pcmcia-cs

interface to pcmcia-cs cardmrg

For example, following small changes to pcmcia-cs scripts can be used to enable WPA support:

Add MODE="Managed" and WPA="y" to the network scheme in /etc/pcmcia/wireless.opts.

Add the following block to the end of start action handler in /etc/pcmcia/wireless:

if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
/usr/local/bin/wpa_supplicant -B -c/etc/wpa_supplicant.conf -i$DEVICE
fi

Add the following block to the end of stop action handler (may need to be separated from other actions) in /etc/pcmcia/wireless:

if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
killall wpa_supplicant
fi

This will make cardmgr start wpa_supplicant when the card is plugged in.

legal

wpa_supplicant is copyright (c) 2003-2007, Jouni Malinen <j[:at:]w1[:dot:]fi> and contributors. All Rights Reserved.

This program is dual-licensed under both the GPL version 2 and BSD license. Either license may be used at your option.

os requirements

Current hardware/software requirements:

Linux kernel 2.4.x or 2.6.x with Linux Wireless Extensions v15 or newer

FreeBSD 6-CURRENT

Microsoft Windows with WinPcap (at least WinXP, may work with other versions)

overview

Wireless networks do not require physical access to the network equipment in the same way as wired networks. This makes it easier for unauthorized users to passively monitor a network and capture all transmitted frames. In addition, unauthorized use of the network is much easier. In many cases, this can happen even without user’s explicit knowledge since the wireless LAN adapter may have been configured to automatically join any available network.

Link-layer encryption can be used to provide a layer of security for wireless networks. The original wireless LAN standard, IEEE 802.11, included a simple encryption mechanism, WEP. However, that proved to be flawed in many areas and network protected with WEP cannot be consider secure. IEEE 802.1X authentication and frequently changed dynamic WEP keys can be used to improve the network security, but even that has inherited security issues due to the use of WEP for encryption. Wi-Fi Protected Access and IEEE 802.11i amendment to the wireless LAN standard introduce a much improvement mechanism for securing wireless networks. IEEE 802.11i enabled networks that are using CCMP (encryption mechanism based on strong cryptographic algorithm AES) can finally be called secure used for applications which require efficient protection against unauthorized access.

wpa_supplicant is an implementation of the WPA Supplicant component, i.e., the part that runs in the client stations. It implements WPA key negotiation with a WPA Authenticator and EAP authentication with Authentication Server. In addition, it controls the roaming and IEEE 802.11 authentication/association of the wireless LAN driver.

wpa_supplicant is designed to be a "daemon" program that runs in the background and acts as the backend component controlling the wireless connection. wpa_supplicant supports separate frontend programs and an example text-based frontend, wpa_cli, is included with wpa_supplicant.

Before wpa_supplicant can do its work, the network interface must be available. That means that the physical device must be present and enabled, and the driver for the device must be loaded. The daemon will exit immediately if the device is not already available.

After wpa_supplicant has configured the network device, higher level configuration such as DHCP may proceed. There are a variety of ways to integrate wpa_supplicant into a machine’s networking scripts, a few of which are described in sections below.

The following steps are used when associating with an AP using WPA:

wpa_supplicant requests the kernel driver to scan neighboring BSSes

wpa_supplicant selects a BSS based on its configuration

wpa_supplicant requests the kernel driver to associate with the chosen BSS

If WPA-EAP: integrated IEEE 802.1X Supplicant completes EAP authentication with the authentication server (proxied by the Authenticator in the AP)

If WPA-EAP: master key is received from the IEEE 802.1X Supplicant

If WPA-PSK: wpa_supplicant uses PSK as the master session key

wpa_supplicant completes WPA 4-Way Handshake and Group Key Handshake with the Authenticator (AP)

wpa_supplicant configures encryption keys for unicast and broadcast

normal data packets can be transmitted and received

quick start

First, make a configuration file, e.g. /etc/wpa_supplicant.conf, that describes the networks you are interested in. See wpa_supplicant.conf(5) for details.

Once the configuration is ready, you can test whether the configuration works by running wpa_supplicant with following command to start it on foreground with debugging enabled:

wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -d

Assuming everything goes fine, you can start using following command to start wpa_supplicant on background without debugging:

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

Please note that if you included more than one driver interface in the build time configuration (.config), you may need to specify which interface to use by including -D<driver name> option on the command line.

supported drivers

Host AP driver for Prism2/2.5/3 (development snapshot/v0.2.x)

(http://hostap.epitest.fi/) Driver needs to be set in Managed mode (iwconfig wlan0 mode managed). Please note that station firmware version needs to be 1.7.0 or newer to work in WPA mode.

Linuxant DriverLoader

(http://www.linuxant.com/driverloader/) with Windows NDIS driver for your wlan card supporting WPA.

Agere Systems Inc. Linux Driver

(http://www.agere.com/support/drivers/) Please note that the driver interface file (driver_hermes.c) and hardware specific include files are not included in the wpa_supplicant distribution. You will need to copy these from the source package of the Agere driver.

madwifi driver for cards based on Atheros chip set (ar521x)

(http://sourceforge.net/projects/madwifi/) Please note that you will need to modify the wpa_supplicant .config file to use the correct path for the madwifi driver root directory (CFLAGS += -I../madwifi/wpa line in example defconfig).

Linux ndiswrapper

(http://ndiswrapper.sourceforge.net/) with Windows NDIS driver.

Broadcom wl.o driver

This is a generic Linux driver for Broadcom IEEE 802.11a/g cards. However, it is proprietary driver that is not publicly available except for couple of exceptions, mainly Broadcom-based APs/wireless routers that use Linux. The driver binary can be downloaded, e.g., from Linksys support site (http://www.linksys.com/support/gpl.asp) for Linksys WRT54G. The GPL tarball includes cross-compiler and the needed header file, wlioctl.h, for compiling wpa_supplicant. This driver support in wpa_supplicant is expected to work also with other devices based on Broadcom driver (assuming the driver includes client mode support).

Intel ipw2100 driver

(http://sourceforge.net/projects/ipw2100/)

Intel ipw2200 driver

(http://sourceforge.net/projects/ipw2200/)

Linux wireless extensions

In theory, any driver that supports Linux wireless extensions can be used with IEEE 802.1X (i.e., not WPA) when using ap_scan=0 option in configuration file.

Wired Ethernet drivers

Use ap_scan=0.

BSD net80211 layer (e.g., Atheros driver)

At the moment, this is for FreeBSD 6-CURRENT branch.

Windows NDIS

The current Windows port requires WinPcap (http://winpcap.polito.it/). See README-Windows.txt for more information.

wpa_supplicant was designed to be portable for different drivers and operating systems. Hopefully, support for more wlan cards and OSes will be added in the future. See developer.txt for more information about the design of wpa_supplicant and porting to other drivers. One main goal is to add full WPA/WPA2 support to Linux wireless extensions to allow new drivers to be supported without having to implement new driver-specific interface code in wpa_supplicant.

supported features

Supported WPA/IEEE 802.11i features:

WPA-PSK ("WPA-Personal")

WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise") Following authentication methods are supported with an integrate IEEE 802.1X Supplicant:

EAP-TLS

EAP-PEAP/MSCHAPv2 (both PEAPv0 and PEAPv1)

EAP-PEAP/TLS (both PEAPv0 and PEAPv1)

EAP-PEAP/GTC (both PEAPv0 and PEAPv1)

EAP-PEAP/OTP (both PEAPv0 and PEAPv1)

EAP-PEAP/MD5-Challenge (both PEAPv0 and PEAPv1)

EAP-TTLS/EAP-MD5-Challenge

EAP-TTLS/EAP-GTC

EAP-TTLS/EAP-OTP

EAP-TTLS/EAP-MSCHAPv2

EAP-TTLS/EAP-TLS

EAP-TTLS/MSCHAPv2

EAP-TTLS/MSCHAP

EAP-TTLS/PAP

EAP-TTLS/CHAP

EAP-SIM

EAP-AKA

EAP-PSK

EAP-PAX

LEAP (note: requires special support from the driver for IEEE 802.11 authentication)

(following methods are supported, but since they do not generate keying material, they cannot be used with WPA or IEEE 802.1X WEP keying)

EAP-MD5-Challenge

EAP-MSCHAPv2

EAP-GTC

EAP-OTP

key management for CCMP, TKIP, WEP104, WEP40

RSN/WPA2 (IEEE 802.11i)

pre-authentication

PMKSA caching


see also

wpa_background wpa_supplicant.conf wpa_cli wpa_passphrase

How can this site be more helpful to YOU ?


give  feedback