4 Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi> and contributors
7 This program is dual-licensed under both the GPL version 2 and BSD
8 license. Either license may be used at your option.
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License version 2 as
19 published by the Free Software Foundation.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 (this copy of the license is in COPYING file)
33 Alternatively, this software may be distributed, used, and modified
34 under the terms of BSD license:
36 Redistribution and use in source and binary forms, with or without
37 modification, are permitted provided that the following conditions are
40 1. Redistributions of source code must retain the above copyright
41 notice, this list of conditions and the following disclaimer.
43 2. Redistributions in binary form must reproduce the above copyright
44 notice, this list of conditions and the following disclaimer in the
45 documentation and/or other materials provided with the distribution.
47 3. Neither the name(s) of the above-listed copyright holder(s) nor the
48 names of its contributors may be used to endorse or promote products
49 derived from this software without specific prior written permission.
51 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 Supported WPA/IEEE 802.11i features:
69 - WPA-PSK ("WPA-Personal")
70 - WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise")
71 Following authentication methods are supported with an integrate IEEE 802.1X
74 * EAP-PEAP/MSCHAPv2 (both PEAPv0 and PEAPv1)
75 * EAP-PEAP/TLS (both PEAPv0 and PEAPv1)
76 * EAP-PEAP/GTC (both PEAPv0 and PEAPv1)
77 * EAP-PEAP/OTP (both PEAPv0 and PEAPv1)
78 * EAP-PEAP/MD5-Challenge (both PEAPv0 and PEAPv1)
79 * EAP-TTLS/EAP-MD5-Challenge
82 * EAP-TTLS/EAP-MSCHAPv2
95 * LEAP (note: requires special support from the driver for IEEE 802.11
97 (following methods are supported, but since they do not generate keying
98 material, they cannot be used with WPA or IEEE 802.1X WEP keying)
103 - key management for CCMP, TKIP, WEP104, WEP40
104 - RSN/WPA2 (IEEE 802.11i)
108 Supported TLS/crypto libraries:
112 Internal TLS/crypto implementation (optional):
113 - can be used in place of an external TLS/crypto library
115 - X.509 certificate processing
120 - minimal size (ca. 50 kB binary, parts of which are already needed for WPA;
121 TLSv1/X.509/ASN.1/RSA/bignum parts are about 25 kB on x86)
127 Current hardware/software requirements:
128 - Linux kernel 2.4.x or 2.6.x with Linux Wireless Extensions v15 or newer
131 - Microsoft Windows with WinPcap (at least WinXP, may work with other versions)
133 Linux drivers that support WPA/WPA2 configuration with the generic
134 Linux wireless extensions (WE-18 or newer). Even though there are
135 number of driver specific interface included in wpa_supplicant, please
136 note that Linux drivers are moving to use generic wireless extensions
137 and driver_wext (-Dwext on wpa_supplicant command line) should be the
138 default option to start with before falling back to driver specific
141 Host AP driver for Prism2/2.5/3 (development snapshot/v0.2.x)
142 (http://hostap.epitest.fi/)
143 Driver need to be set in Managed mode ('iwconfig wlan0 mode managed').
144 Please note that station firmware version needs to be 1.7.0 or newer
147 Linuxant DriverLoader (http://www.linuxant.com/driverloader/)
148 with Windows NDIS driver for your wlan card supporting WPA.
150 madwifi driver for cards based on Atheros chip set (ar521x)
151 (http://sourceforge.net/projects/madwifi/)
152 Please note that you will need to modify the wpa_supplicant .config
153 file to use the correct path for the madwifi driver root directory
154 (CFLAGS += -I../madwifi/wpa line in example defconfig).
156 Linux ndiswrapper (http://ndiswrapper.sourceforge.net/) with
159 In theory, any driver that supports Linux wireless extensions can be
160 used with IEEE 802.1X (i.e., not WPA) when using ap_scan=0 option in
163 Wired Ethernet drivers (with ap_scan=0)
165 BSD net80211 layer (e.g., Atheros driver)
166 At the moment, this is for FreeBSD 6-CURRENT branch and NetBSD-current.
169 The current Windows port requires WinPcap (http://winpcap.polito.it/).
170 See README-Windows.txt for more information.
172 wpa_supplicant was designed to be portable for different drivers and
173 operating systems. Hopefully, support for more wlan cards and OSes will be
174 added in the future. See developer's documentation
175 (http://hostap.epitest.fi/wpa_supplicant/devel/) for more information about the
176 design of wpa_supplicant and porting to other drivers. One main goal
177 is to add full WPA/WPA2 support to Linux wireless extensions to allow
178 new drivers to be supported without having to implement new
179 driver-specific interface code in wpa_supplicant.
181 Optional libraries for layer2 packet processing:
182 - libpcap (tested with 0.7.2, most relatively recent versions assumed to work,
183 this is likely to be available with most distributions,
185 - libdnet (tested with v1.4, most versions assumed to work,
186 http://libdnet.sourceforge.net/)
188 These libraries are _not_ used in the default Linux build. Instead,
189 internal Linux specific implementation is used. libpcap/libdnet are
190 more portable and they can be used by adding CONFIG_L2_PACKET=pcap into
191 .config. They may also be selected automatically for other operating
192 systems. In case of Windows builds, WinPcap is used by default
193 (CONFIG_L2_PACKET=winpcap).
196 Optional libraries for EAP-TLS, EAP-PEAP, and EAP-TTLS:
197 - OpenSSL (tested with 0.9.7c and 0.9.7d, and 0.9.8 versions; assumed to
198 work with most relatively recent versions; this is likely to be
199 available with most distributions, http://www.openssl.org/)
201 - internal TLSv1 implementation
203 TLS options for EAP-FAST:
204 - OpenSSL 0.9.8d _with_ openssl-0.9.8d-tls-extensions.patch applied
205 (i.e., the default OpenSSL package does not include support for
206 extensions needed for EAP-FAST)
207 - internal TLSv1 implementation
209 One of these libraries is needed when EAP-TLS, EAP-PEAP, EAP-TTLS, or
210 EAP-FAST support is enabled. WPA-PSK mode does not require this or EAPOL/EAP
211 implementation. A configuration file, .config, for compilation is
212 needed to enable IEEE 802.1X/EAPOL and EAP methods. Note that EAP-MD5,
213 EAP-GTC, EAP-OTP, and EAP-MSCHAPV2 cannot be used alone with WPA, so
214 they should only be enabled if testing the EAPOL/EAP state
215 machines. However, there can be used as inner authentication
216 algorithms with EAP-PEAP and EAP-TTLS.
218 See Building and installing section below for more detailed
219 information about the wpa_supplicant build time configuration.
226 The original security mechanism of IEEE 802.11 standard was not
227 designed to be strong and has proven to be insufficient for most
228 networks that require some kind of security. Task group I (Security)
229 of IEEE 802.11 working group (http://www.ieee802.org/11/) has worked
230 to address the flaws of the base standard and has in practice
231 completed its work in May 2004. The IEEE 802.11i amendment to the IEEE
232 802.11 standard was approved in June 2004 and published in July 2004.
234 Wi-Fi Alliance (http://www.wi-fi.org/) used a draft version of the
235 IEEE 802.11i work (draft 3.0) to define a subset of the security
236 enhancements that can be implemented with existing wlan hardware. This
237 is called Wi-Fi Protected Access<TM> (WPA). This has now become a
238 mandatory component of interoperability testing and certification done
239 by Wi-Fi Alliance. Wi-Fi provides information about WPA at its web
240 site (http://www.wi-fi.org/OpenSection/protected_access.asp).
242 IEEE 802.11 standard defined wired equivalent privacy (WEP) algorithm
243 for protecting wireless networks. WEP uses RC4 with 40-bit keys,
244 24-bit initialization vector (IV), and CRC32 to protect against packet
245 forgery. All these choices have proven to be insufficient: key space is
246 too small against current attacks, RC4 key scheduling is insufficient
247 (beginning of the pseudorandom stream should be skipped), IV space is
248 too small and IV reuse makes attacks easier, there is no replay
249 protection, and non-keyed authentication does not protect against bit
250 flipping packet data.
252 WPA is an intermediate solution for the security issues. It uses
253 Temporal Key Integrity Protocol (TKIP) to replace WEP. TKIP is a
254 compromise on strong security and possibility to use existing
255 hardware. It still uses RC4 for the encryption like WEP, but with
256 per-packet RC4 keys. In addition, it implements replay protection,
257 keyed packet authentication mechanism (Michael MIC).
259 Keys can be managed using two different mechanisms. WPA can either use
260 an external authentication server (e.g., RADIUS) and EAP just like
261 IEEE 802.1X is using or pre-shared keys without need for additional
262 servers. Wi-Fi calls these "WPA-Enterprise" and "WPA-Personal",
263 respectively. Both mechanisms will generate a master session key for
264 the Authenticator (AP) and Supplicant (client station).
266 WPA implements a new key handshake (4-Way Handshake and Group Key
267 Handshake) for generating and exchanging data encryption keys between
268 the Authenticator and Supplicant. This handshake is also used to
269 verify that both Authenticator and Supplicant know the master session
270 key. These handshakes are identical regardless of the selected key
271 management mechanism (only the method for generating master session
279 The design for parts of IEEE 802.11i that were not included in WPA has
280 finished (May 2004) and this amendment to IEEE 802.11 was approved in
281 June 2004. Wi-Fi Alliance is using the final IEEE 802.11i as a new
282 version of WPA called WPA2. This includes, e.g., support for more
283 robust encryption algorithm (CCMP: AES in Counter mode with CBC-MAC)
284 to replace TKIP and optimizations for handoff (reduced number of
285 messages in initial key handshake, pre-authentication, and PMKSA caching).
292 wpa_supplicant is an implementation of the WPA Supplicant component,
293 i.e., the part that runs in the client stations. It implements WPA key
294 negotiation with a WPA Authenticator and EAP authentication with
295 Authentication Server. In addition, it controls the roaming and IEEE
296 802.11 authentication/association of the wlan driver.
298 wpa_supplicant is designed to be a "daemon" program that runs in the
299 background and acts as the backend component controlling the wireless
300 connection. wpa_supplicant supports separate frontend programs and an
301 example text-based frontend, wpa_cli, is included with wpa_supplicant.
303 Following steps are used when associating with an AP using WPA:
305 - wpa_supplicant requests the kernel driver to scan neighboring BSSes
306 - wpa_supplicant selects a BSS based on its configuration
307 - wpa_supplicant requests the kernel driver to associate with the chosen
309 - If WPA-EAP: integrated IEEE 802.1X Supplicant completes EAP
310 authentication with the authentication server (proxied by the
311 Authenticator in the AP)
312 - If WPA-EAP: master key is received from the IEEE 802.1X Supplicant
313 - If WPA-PSK: wpa_supplicant uses PSK as the master session key
314 - wpa_supplicant completes WPA 4-Way Handshake and Group Key Handshake
315 with the Authenticator (AP)
316 - wpa_supplicant configures encryption keys for unicast and broadcast
317 - normal data packets can be transmitted and received
321 Building and installing
322 -----------------------
324 In order to be able to build wpa_supplicant, you will first need to
325 select which parts of it will be included. This is done by creating a
326 build time configuration file, .config, in the wpa_supplicant root
327 directory. Configuration options are text lines using following
328 format: CONFIG_<option>=y. Lines starting with # are considered
329 comments and are ignored. See defconfig file for an example configuration
330 and a list of available options and additional notes.
332 The build time configuration can be used to select only the needed
333 features and limit the binary size and requirements for external
334 libraries. The main configuration parts are the selection of which
335 driver interfaces (e.g., hostap, madwifi, ..) and which authentication
336 methods (e.g., EAP-TLS, EAP-PEAP, ..) are included.
338 Following build time configuration options are used to control IEEE
339 802.1X/EAPOL and EAP state machines and all EAP methods. Including
340 TLS, PEAP, or TTLS will require linking wpa_supplicant with OpenSSL
341 library for TLS implementation. Alternatively, GnuTLS or the internal
342 TLSv1 implementation can be used for TLS functionaly.
344 CONFIG_IEEE8021X_EAPOL=y
346 CONFIG_EAP_MSCHAPV2=y
361 Following option can be used to include GSM SIM/USIM interface for GSM/UMTS
362 authentication algorithm (for EAP-SIM/EAP-AKA). This requires pcsc-lite
363 (http://www.linuxnet.com/) for smart card access.
367 Following options can be added to .config to select which driver
368 interfaces are included.
370 CONFIG_DRIVER_HOSTAP=y
371 CONFIG_DRIVER_MADWIFI=y
376 Following example includes all features and driver interfaces that are
377 included in the wpa_supplicant package:
379 CONFIG_DRIVER_HOSTAP=y
380 CONFIG_DRIVER_MADWIFI=y
384 CONFIG_IEEE8021X_EAPOL=y
386 CONFIG_EAP_MSCHAPV2=y
402 EAP-PEAP and EAP-TTLS will automatically include configured EAP
403 methods (MD5, OTP, GTC, MSCHAPV2) for inner authentication selection.
406 After you have created a configuration file, you can build
407 wpa_supplicant and wpa_cli with 'make' command. You may then install
408 the binaries to a suitable system directory, e.g., /usr/local/bin.
412 # build wpa_supplicant and wpa_cli
414 # install binaries (this may need root privileges)
415 cp wpa_cli wpa_supplicant /usr/local/bin
418 You will need to make a configuration file, e.g.,
419 /etc/wpa_supplicant.conf, with network configuration for the networks
420 you are going to use. Configuration file section below includes
421 explanation fo the configuration file format and includes various
422 examples. Once the configuration is ready, you can test whether the
423 configuration work by first running wpa_supplicant with following
424 command to start it on foreground with debugging enabled:
426 wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -d
428 Assuming everything goes fine, you can start using following command
429 to start wpa_supplicant on background without debugging:
431 wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
433 Please note that if you included more than one driver interface in the
434 build time configuration (.config), you may need to specify which
435 interface to use by including -D<driver name> option on the command
436 line. See following section for more details on command line options
445 wpa_supplicant [-BddfhKLqqtuvwW] [-P<pid file>] [-g<global ctrl>] \
446 -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
447 [-b<br_ifname> [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
448 [-p<driver_param>] [-b<br_ifname>] ...]
451 -b = optional bridge interface name
452 -B = run daemon in the background
453 -c = Configuration file
454 -C = ctrl_interface parameter (only used if -c is not)
456 -d = increase debugging verbosity (-dd even more)
457 -D = driver name (can be multiple drivers: nl80211,wext)
458 -f = Log output to default log location (normally /tmp)
459 -g = global ctrl_interface
460 -K = include keys (passwords, etc.) in debug output
461 -t = include timestamp in debug messages
462 -h = show this help text
463 -L = show license (GPL and BSD)
464 -p = driver parameters
466 -q = decrease debugging verbosity (-qq even less)
467 -u = enable DBus control interface
469 -w = wait for interface to be added, if needed
470 -W = wait for a control interface monitor before starting
471 -N = start describing new interface
474 hostap = Host AP driver (Intersil Prism2/2.5/3) [default]
475 (this can also be used with Linuxant DriverLoader)
476 madwifi = MADWIFI 802.11 support (Atheros, etc.) (deprecated; use wext)
477 wext = Linux wireless extensions (generic)
478 wired = wpa_supplicant wired Ethernet driver
479 roboswitch = wpa_supplicant Broadcom switch driver
480 bsd = BSD 802.11 support (Atheros, etc.)
481 ndis = Windows NDIS driver
483 In most common cases, wpa_supplicant is started with
485 wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
487 This makes the process fork into background.
489 The easiest way to debug problems, and to get debug log for bug
490 reports, is to start wpa_supplicant on foreground with debugging
493 wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d
495 If the specific driver wrapper is not known beforehand, it is possible
496 to specify multiple comma separated driver wrappers on the command
497 line. wpa_supplicant will use the first driver wrapper that is able to
498 initialize the interface.
500 wpa_supplicant -Dnl80211,wext -c/etc/wpa_supplicant.conf -iwlan0
503 wpa_supplicant can control multiple interfaces (radios) either by
504 running one process for each interface separately or by running just
505 one process and list of options at command line. Each interface is
506 separated with -N argument. As an example, following command would
507 start wpa_supplicant for two interfaces:
510 -c wpa1.conf -i wlan0 -D hostap -N \
511 -c wpa2.conf -i ath0 -D madwifi
514 If the interface is added in a Linux bridge (e.g., br0), the bridge
515 interface needs to be configured to wpa_supplicant in addition to the
518 wpa_supplicant -cw.conf -Dmadwifi -iath0 -bbr0
524 wpa_supplicant is configured using a text file that lists all accepted
525 networks and security policies, including pre-shared keys. See
526 example configuration file, wpa_supplicant.conf, for detailed
527 information about the configuration format and supported fields.
529 Changes to configuration file can be reloaded be sending SIGHUP signal
530 to wpa_supplicant ('killall -HUP wpa_supplicant'). Similarly,
531 reloading can be triggered with 'wpa_cli reconfigure' command.
533 Configuration file can include one or more network blocks, e.g., one
534 for each used SSID. wpa_supplicant will automatically select the best
535 betwork based on the order of network blocks in the configuration
536 file, network security level (WPA/WPA2 is preferred), and signal
539 Example configuration files for some common configurations:
541 1) WPA-Personal (PSK) as home network and WPA-Enterprise with EAP-TLS as work
544 # allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
545 ctrl_interface=/var/run/wpa_supplicant
546 ctrl_interface_group=wheel
548 # home network; allow all valid ciphers
553 psk="very secret passphrase"
556 # work network; use EAP-TLS with WPA; allow only CCMP and TKIP ciphers
564 identity="user@example.com"
565 ca_cert="/etc/cert/ca.pem"
566 client_cert="/etc/cert/user.pem"
567 private_key="/etc/cert/user.prv"
568 private_key_passwd="password"
572 2) WPA-RADIUS/EAP-PEAP/MSCHAPv2 with RADIUS servers that use old peaplabel
573 (e.g., Funk Odyssey and SBR, Meetinghouse Aegis, Interlink RAD-Series)
575 ctrl_interface=/var/run/wpa_supplicant
576 ctrl_interface_group=wheel
582 identity="user@example.com"
584 ca_cert="/etc/cert/ca.pem"
586 phase2="auth=MSCHAPV2"
590 3) EAP-TTLS/EAP-MD5-Challenge configuration with anonymous identity for the
591 unencrypted use. Real identity is sent only within an encrypted TLS tunnel.
593 ctrl_interface=/var/run/wpa_supplicant
594 ctrl_interface_group=wheel
600 identity="user@example.com"
601 anonymous_identity="anonymous@example.com"
603 ca_cert="/etc/cert/ca.pem"
608 4) IEEE 802.1X (i.e., no WPA) with dynamic WEP keys (require both unicast and
609 broadcast); use EAP-TLS for authentication
611 ctrl_interface=/var/run/wpa_supplicant
612 ctrl_interface_group=wheel
618 identity="user@example.com"
619 ca_cert="/etc/cert/ca.pem"
620 client_cert="/etc/cert/user.pem"
621 private_key="/etc/cert/user.prv"
622 private_key_passwd="password"
627 5) Catch all example that allows more or less all configuration modes. The
628 configuration options are used based on what security policy is used in the
629 selected SSID. This is mostly for testing and is not recommended for normal
632 ctrl_interface=/var/run/wpa_supplicant
633 ctrl_interface_group=wheel
637 key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
639 group=CCMP TKIP WEP104 WEP40
640 psk="very secret passphrase"
642 identity="user@example.com"
644 ca_cert="/etc/cert/ca.pem"
645 client_cert="/etc/cert/user.pem"
646 private_key="/etc/cert/user.prv"
647 private_key_passwd="password"
649 ca_cert2="/etc/cert/ca2.pem"
650 client_cert2="/etc/cer/user.pem"
651 private_key2="/etc/cer/user.prv"
652 private_key2_passwd="password"
656 6) Authentication for wired Ethernet. This can be used with 'wired' or
657 'roboswitch' interface (-Dwired or -Droboswitch on command line).
659 ctrl_interface=/var/run/wpa_supplicant
660 ctrl_interface_group=wheel
675 Some EAP authentication methods require use of certificates. EAP-TLS
676 uses both server side and client certificates whereas EAP-PEAP and
677 EAP-TTLS only require the server side certificate. When client
678 certificate is used, a matching private key file has to also be
679 included in configuration. If the private key uses a passphrase, this
680 has to be configured in wpa_supplicant.conf ("private_key_passwd").
682 wpa_supplicant supports X.509 certificates in PEM and DER
683 formats. User certificate and private key can be included in the same
686 If the user certificate and private key is received in PKCS#12/PFX
687 format, they need to be converted to suitable PEM/DER format for
688 wpa_supplicant. This can be done, e.g., with following commands:
690 # convert client certificate and private key to PEM format
691 openssl pkcs12 -in example.pfx -out user.pem -clcerts
692 # convert CA certificate (if included in PFX file) to PEM format
693 openssl pkcs12 -in example.pfx -out ca.pem -cacerts -nokeys
700 wpa_cli is a text-based frontend program for interacting with
701 wpa_supplicant. It is used to query current status, change
702 configuration, trigger events, and request interactive user input.
704 wpa_cli can show the current authentication status, selected security
705 mode, dot11 and dot1x MIBs, etc. In addition, it can configure some
706 variables like EAPOL state machine parameters and trigger events like
707 reassociation and IEEE 802.1X logoff/logon. wpa_cli provides a user
708 interface to request authentication information, like username and
709 password, if these are not included in the configuration. This can be
710 used to implement, e.g., one-time-passwords or generic token card
711 authentication where the authentication is based on a
712 challenge-response that uses an external device for generating the
715 The control interface of wpa_supplicant can be configured to allow
716 non-root user access (ctrl_interface_group in the configuration
717 file). This makes it possible to run wpa_cli with a normal user
720 wpa_cli supports two modes: interactive and command line. Both modes
721 share the same command set and the main difference is in interactive
722 mode providing access to unsolicited messages (event messages,
723 username/password requests).
725 Interactive mode is started when wpa_cli is executed without including
726 the command as a command line parameter. Commands are then entered on
727 the wpa_cli prompt. In command line mode, the same commands are
728 entered as command line arguments for wpa_cli.
731 Interactive authentication parameters request
733 When wpa_supplicant need authentication parameters, like username and
734 password, which are not present in the configuration file, it sends a
735 request message to all attached frontend programs, e.g., wpa_cli in
736 interactive mode. wpa_cli shows these requests with
737 "CTRL-REQ-<type>-<id>:<text>" prefix. <type> is IDENTITY, PASSWORD, or
738 OTP (one-time-password). <id> is a unique identifier for the current
739 network. <text> is description of the request. In case of OTP request,
740 it includes the challenge from the authentication server.
742 The reply to these requests can be given with 'identity', 'password',
743 and 'otp' commands. <id> needs to be copied from the the matching
744 request. 'password' and 'otp' commands can be used regardless of
745 whether the request was for PASSWORD or OTP. The main difference
746 between these two commands is that values given with 'password' are
747 remembered as long as wpa_supplicant is running whereas values given
748 with 'otp' are used only once and then forgotten, i.e., wpa_supplicant
749 will ask frontend for a new value for every use. This can be used to
750 implement one-time-password lists and generic token card -based
753 Example request for password and a matching reply:
755 CTRL-REQ-PASSWORD-1:Password needed for SSID foobar
756 > password 1 mysecretpassword
758 Example request for generic token card challenge-response:
760 CTRL-REQ-OTP-2:Challenge 1235663 needed for SSID foobar
766 status = get current WPA/EAPOL/EAP status
767 mib = get MIB variables (dot1x, dot11)
768 help = show this usage help
769 interface [ifname] = show interfaces/select interface
770 level <debug level> = change debug level
771 license = show full wpa_cli license
772 logoff = IEEE 802.1X EAPOL state machine logoff
773 logon = IEEE 802.1X EAPOL state machine logon
774 set = set variables (shows list of variables when run without arguments)
775 pmksa = show PMKSA cache
776 reassociate = force reassociation
777 reconfigure = force wpa_supplicant to re-read its configuration file
778 preauthenticate <BSSID> = force preauthentication
779 identity <network id> <identity> = configure identity for an SSID
780 password <network id> <password> = configure password for an SSID
781 pin <network id> <pin> = configure pin for an SSID
782 otp <network id> <password> = configure one-time-password for an SSID
783 passphrase <network id> <passphrase> = configure private key passphrase
785 bssid <network id> <BSSID> = set preferred BSSID for an SSID
786 list_networks = list configured networks
787 select_network <network id> = select a network (disable others)
788 enable_network <network id> = enable a network
789 disable_network <network id> = disable a network
790 add_network = add a network
791 remove_network <network id> = remove a network
792 set_network <network id> <variable> <value> = set network variables (shows
793 list of variables when run without arguments)
794 get_network <network id> <variable> = get network variables
795 save_config = save the current configuration
796 disconnect = disconnect and wait for reassociate command before connecting
797 scan = request new BSS scan
798 scan_results = get latest scan results
799 get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> = get capabilies
800 terminate = terminate wpa_supplicant
804 wpa_cli command line options
806 wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] [-a<action file>] \
807 [-P<pid file>] [-g<global ctrl>] [command..]
808 -h = help (show this usage text)
809 -v = shown version information
810 -a = run in daemon mode executing the action file based on events from
812 -B = run a daemon in the background
813 default path: /var/run/wpa_supplicant
814 default interface: first interface found in socket path
817 Using wpa_cli to run external program on connect/disconnect
818 -----------------------------------------------------------
820 wpa_cli can used to run external programs whenever wpa_supplicant
821 connects or disconnects from a network. This can be used, e.g., to
822 update network configuration and/or trigget DHCP client to update IP
825 One wpa_cli process in "action" mode needs to be started for each
826 interface. For example, the following command starts wpa_cli for the
827 default ingterface (-i can be used to select the interface in case of
828 more than one interface being used at the same time):
830 wpa_cli -a/sbin/wpa_action.sh -B
832 The action file (-a option, /sbin/wpa_action.sh in this example) will
833 be executed whenever wpa_supplicant completes authentication (connect
834 event) or detects disconnection). The action script will be called
835 with two command line arguments: interface name and event (CONNECTED
836 or DISCONNECTED). If the action script needs to get more information
837 about the current network, it can use 'wpa_cli status' to query
838 wpa_supplicant for more information.
840 Following example can be used as a simple template for an action
848 if [ "$CMD" = "CONNECTED" ]; then
849 SSID=`wpa_cli -i$IFNAME status | grep ^ssid= | cut -f2- -d=`
850 # configure network, signal DHCP client, etc.
853 if [ "$CMD" = "DISCONNECTED" ]; then
854 # remove network configuration, if needed
860 Integrating with pcmcia-cs/cardmgr scripts
861 ------------------------------------------
863 wpa_supplicant needs to be running when using a wireless network with
864 WPA. It can be started either from system startup scripts or from
865 pcmcia-cs/cardmgr scripts (when using PC Cards). WPA handshake must be
866 completed before data frames can be exchanged, so wpa_supplicant
867 should be started before DHCP client.
869 For example, following small changes to pcmcia-cs scripts can be used
870 to enable WPA support:
872 Add MODE="Managed" and WPA="y" to the network scheme in
873 /etc/pcmcia/wireless.opts.
875 Add the following block to the end of 'start' action handler in
876 /etc/pcmcia/wireless:
878 if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
879 /usr/local/bin/wpa_supplicant -B -c/etc/wpa_supplicant.conf \
883 Add the following block to the end of 'stop' action handler (may need
884 to be separated from other actions) in /etc/pcmcia/wireless:
886 if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
887 killall wpa_supplicant
890 This will make cardmgr start wpa_supplicant when the card is plugged
895 Dynamic interface add and operation without configuration files
896 ---------------------------------------------------------------
898 wpa_supplicant can be started without any configuration files or
899 network interfaces. When used in this way, a global (i.e., per
900 wpa_supplicant process) control interface is used to add and remove
901 network interfaces. Each network interface can then be configured
902 through a per-network interface control interface. For example,
903 following commands show how to start wpa_supplicant without any
904 network interfaces and then add a network interface and configure a
907 # Start wpa_supplicant in the background
908 wpa_supplicant -g/var/run/wpa_supplicant-global -B
910 # Add a new interface (wlan0, no configuration file, driver=wext, and
911 # enable control interface)
912 wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan0 \
913 "" wext /var/run/wpa_supplicant
915 # Configure a network using the newly added network interface:
916 wpa_cli -iwlan0 add_network
917 wpa_cli -iwlan0 set_network 0 ssid '"test"'
918 wpa_cli -iwlan0 set_network 0 key_mgmt WPA-PSK
919 wpa_cli -iwlan0 set_network 0 psk '"12345678"'
920 wpa_cli -iwlan0 set_network 0 pairwise TKIP
921 wpa_cli -iwlan0 set_network 0 group TKIP
922 wpa_cli -iwlan0 set_network 0 proto WPA
923 wpa_cli -iwlan0 enable_network 0
925 # At this point, the new network interface should start trying to associate
926 # with the WPA-PSK network using SSID test.
928 # Remove network interface
929 wpa_cli -g/var/run/wpa_supplicant-global interface_remove wlan0
935 To minimize the size of code that needs to be run with root privileges
936 (e.g., to control wireless interface operation), wpa_supplicant
937 supports optional privilege separation. If enabled, this separates the
938 privileged operations into a separate process (wpa_priv) while leaving
939 rest of the code (e.g., EAP authentication and WPA handshakes) into an
940 unprivileged process (wpa_supplicant) that can be run as non-root
941 user. Privilege separation restricts the effects of potential software
942 errors by containing the majority of the code in an unprivileged
943 process to avoid full system compromise.
945 Privilege separation is not enabled by default and it can be enabled
946 by adding CONFIG_PRIVSEP=y to the build configuration (.config). When
947 enabled, the privileged operations (driver wrapper and l2_packet) are
948 linked into a separate daemon program, wpa_priv. The unprivileged
949 program, wpa_supplicant, will be built with a special driver/l2_packet
950 wrappers that communicate with the privileged wpa_priv process to
951 perform the needed operations. wpa_priv can control what privileged
954 wpa_priv needs to be run with network admin privileges (usually, root
955 user). It opens a UNIX domain socket for each interface that is
956 included on the command line; any other interface will be off limits
957 for wpa_supplicant in this kind of configuration. After this,
958 wpa_supplicant can be run as a non-root user (e.g., all standard users
959 on a laptop or as a special non-privileged user account created just
960 for this purpose to limit access to user files even further).
963 Example configuration:
964 - create user group for users that are allowed to use wpa_supplicant
965 ('wpapriv' in this example) and assign users that should be able to
966 use wpa_supplicant into that group
967 - create /var/run/wpa_priv directory for UNIX domain sockets and control
968 user access by setting it accessible only for the wpapriv group:
969 mkdir /var/run/wpa_priv
970 chown root:wpapriv /var/run/wpa_priv
971 chmod 0750 /var/run/wpa_priv
972 - start wpa_priv as root (e.g., from system startup scripts) with the
973 enabled interfaces configured on the command line:
974 wpa_priv -B -P /var/run/wpa_priv.pid wext:ath0
975 - run wpa_supplicant as non-root with a user that is in wpapriv group:
976 wpa_supplicant -i ath0 -c wpa_supplicant.conf
978 wpa_priv does not use the network interface before wpa_supplicant is
979 started, so it is fine to include network interfaces that are not
980 available at the time wpa_priv is started. As an alternative, wpa_priv
981 can be started when an interface is added (hotplug/udev/etc. scripts).
982 wpa_priv can control multiple interface with one process, but it is
983 also possible to run multiple wpa_priv processes at the same time, if