README 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. WPA Supplicant
  2. ==============
  3. Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi> and contributors
  4. All Rights Reserved.
  5. This program is dual-licensed under both the GPL version 2 and BSD
  6. license. Either license may be used at your option.
  7. License
  8. -------
  9. GPL v2:
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License version 2 as
  12. published by the Free Software Foundation.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. (this copy of the license is in COPYING file)
  21. Alternatively, this software may be distributed, used, and modified
  22. under the terms of BSD license:
  23. Redistribution and use in source and binary forms, with or without
  24. modification, are permitted provided that the following conditions are
  25. met:
  26. 1. Redistributions of source code must retain the above copyright
  27. notice, this list of conditions and the following disclaimer.
  28. 2. Redistributions in binary form must reproduce the above copyright
  29. notice, this list of conditions and the following disclaimer in the
  30. documentation and/or other materials provided with the distribution.
  31. 3. Neither the name(s) of the above-listed copyright holder(s) nor the
  32. names of its contributors may be used to endorse or promote products
  33. derived from this software without specific prior written permission.
  34. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  35. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  36. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  37. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  38. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  39. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  40. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  41. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  42. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  43. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  44. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  45. Features
  46. --------
  47. Supported WPA/IEEE 802.11i features:
  48. - WPA-PSK ("WPA-Personal")
  49. - WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise")
  50. Following authentication methods are supported with an integrate IEEE 802.1X
  51. Supplicant:
  52. * EAP-TLS
  53. * EAP-PEAP/MSCHAPv2 (both PEAPv0 and PEAPv1)
  54. * EAP-PEAP/TLS (both PEAPv0 and PEAPv1)
  55. * EAP-PEAP/GTC (both PEAPv0 and PEAPv1)
  56. * EAP-PEAP/OTP (both PEAPv0 and PEAPv1)
  57. * EAP-PEAP/MD5-Challenge (both PEAPv0 and PEAPv1)
  58. * EAP-TTLS/EAP-MD5-Challenge
  59. * EAP-TTLS/EAP-GTC
  60. * EAP-TTLS/EAP-OTP
  61. * EAP-TTLS/EAP-MSCHAPv2
  62. * EAP-TTLS/EAP-TLS
  63. * EAP-TTLS/MSCHAPv2
  64. * EAP-TTLS/MSCHAP
  65. * EAP-TTLS/PAP
  66. * EAP-TTLS/CHAP
  67. * EAP-SIM
  68. * EAP-AKA
  69. * EAP-PSK
  70. * EAP-PAX
  71. * EAP-SAKE
  72. * EAP-IKEv2
  73. * EAP-GPSK
  74. * LEAP (note: requires special support from the driver for IEEE 802.11
  75. authentication)
  76. (following methods are supported, but since they do not generate keying
  77. material, they cannot be used with WPA or IEEE 802.1X WEP keying)
  78. * EAP-MD5-Challenge
  79. * EAP-MSCHAPv2
  80. * EAP-GTC
  81. * EAP-OTP
  82. - key management for CCMP, TKIP, WEP104, WEP40
  83. - RSN/WPA2 (IEEE 802.11i)
  84. * pre-authentication
  85. * PMKSA caching
  86. Supported TLS/crypto libraries:
  87. - OpenSSL (default)
  88. - GnuTLS
  89. Internal TLS/crypto implementation (optional):
  90. - can be used in place of an external TLS/crypto library
  91. - TLSv1
  92. - X.509 certificate processing
  93. - PKCS #1
  94. - ASN.1
  95. - RSA
  96. - bignum
  97. - minimal size (ca. 50 kB binary, parts of which are already needed for WPA;
  98. TLSv1/X.509/ASN.1/RSA/bignum parts are about 25 kB on x86)
  99. Requirements
  100. ------------
  101. Current hardware/software requirements:
  102. - Linux kernel 2.4.x or 2.6.x with Linux Wireless Extensions v15 or newer
  103. - FreeBSD 6-CURRENT
  104. - NetBSD-current
  105. - Microsoft Windows with WinPcap (at least WinXP, may work with other versions)
  106. - drivers:
  107. Linux drivers that support WPA/WPA2 configuration with the generic
  108. Linux wireless extensions (WE-18 or newer). Even though there are
  109. number of driver specific interface included in wpa_supplicant, please
  110. note that Linux drivers are moving to use generic wireless extensions
  111. and driver_wext (-Dwext on wpa_supplicant command line) should be the
  112. default option to start with before falling back to driver specific
  113. interface.
  114. In theory, any driver that supports Linux wireless extensions can be
  115. used with IEEE 802.1X (i.e., not WPA) when using ap_scan=0 option in
  116. configuration file.
  117. Wired Ethernet drivers (with ap_scan=0)
  118. BSD net80211 layer (e.g., Atheros driver)
  119. At the moment, this is for FreeBSD 6-CURRENT branch and NetBSD-current.
  120. Windows NDIS
  121. The current Windows port requires WinPcap (http://winpcap.polito.it/).
  122. See README-Windows.txt for more information.
  123. wpa_supplicant was designed to be portable for different drivers and
  124. operating systems. Hopefully, support for more wlan cards and OSes will be
  125. added in the future. See developer's documentation
  126. (http://hostap.epitest.fi/wpa_supplicant/devel/) for more information about the
  127. design of wpa_supplicant and porting to other drivers. One main goal
  128. is to add full WPA/WPA2 support to Linux wireless extensions to allow
  129. new drivers to be supported without having to implement new
  130. driver-specific interface code in wpa_supplicant.
  131. Optional libraries for layer2 packet processing:
  132. - libpcap (tested with 0.7.2, most relatively recent versions assumed to work,
  133. this is likely to be available with most distributions,
  134. http://tcpdump.org/)
  135. - libdnet (tested with v1.4, most versions assumed to work,
  136. http://libdnet.sourceforge.net/)
  137. These libraries are _not_ used in the default Linux build. Instead,
  138. internal Linux specific implementation is used. libpcap/libdnet are
  139. more portable and they can be used by adding CONFIG_L2_PACKET=pcap into
  140. .config. They may also be selected automatically for other operating
  141. systems. In case of Windows builds, WinPcap is used by default
  142. (CONFIG_L2_PACKET=winpcap).
  143. Optional libraries for EAP-TLS, EAP-PEAP, and EAP-TTLS:
  144. - OpenSSL (tested with 0.9.7c and 0.9.7d, and 0.9.8 versions; assumed to
  145. work with most relatively recent versions; this is likely to be
  146. available with most distributions, http://www.openssl.org/)
  147. - GnuTLS
  148. - internal TLSv1 implementation
  149. TLS options for EAP-FAST:
  150. - OpenSSL 0.9.8d _with_ openssl-0.9.8d-tls-extensions.patch applied
  151. (i.e., the default OpenSSL package does not include support for
  152. extensions needed for EAP-FAST)
  153. - internal TLSv1 implementation
  154. One of these libraries is needed when EAP-TLS, EAP-PEAP, EAP-TTLS, or
  155. EAP-FAST support is enabled. WPA-PSK mode does not require this or EAPOL/EAP
  156. implementation. A configuration file, .config, for compilation is
  157. needed to enable IEEE 802.1X/EAPOL and EAP methods. Note that EAP-MD5,
  158. EAP-GTC, EAP-OTP, and EAP-MSCHAPV2 cannot be used alone with WPA, so
  159. they should only be enabled if testing the EAPOL/EAP state
  160. machines. However, there can be used as inner authentication
  161. algorithms with EAP-PEAP and EAP-TTLS.
  162. See Building and installing section below for more detailed
  163. information about the wpa_supplicant build time configuration.
  164. WPA
  165. ---
  166. The original security mechanism of IEEE 802.11 standard was not
  167. designed to be strong and has proven to be insufficient for most
  168. networks that require some kind of security. Task group I (Security)
  169. of IEEE 802.11 working group (http://www.ieee802.org/11/) has worked
  170. to address the flaws of the base standard and has in practice
  171. completed its work in May 2004. The IEEE 802.11i amendment to the IEEE
  172. 802.11 standard was approved in June 2004 and published in July 2004.
  173. Wi-Fi Alliance (http://www.wi-fi.org/) used a draft version of the
  174. IEEE 802.11i work (draft 3.0) to define a subset of the security
  175. enhancements that can be implemented with existing wlan hardware. This
  176. is called Wi-Fi Protected Access<TM> (WPA). This has now become a
  177. mandatory component of interoperability testing and certification done
  178. by Wi-Fi Alliance. Wi-Fi provides information about WPA at its web
  179. site (http://www.wi-fi.org/OpenSection/protected_access.asp).
  180. IEEE 802.11 standard defined wired equivalent privacy (WEP) algorithm
  181. for protecting wireless networks. WEP uses RC4 with 40-bit keys,
  182. 24-bit initialization vector (IV), and CRC32 to protect against packet
  183. forgery. All these choices have proven to be insufficient: key space is
  184. too small against current attacks, RC4 key scheduling is insufficient
  185. (beginning of the pseudorandom stream should be skipped), IV space is
  186. too small and IV reuse makes attacks easier, there is no replay
  187. protection, and non-keyed authentication does not protect against bit
  188. flipping packet data.
  189. WPA is an intermediate solution for the security issues. It uses
  190. Temporal Key Integrity Protocol (TKIP) to replace WEP. TKIP is a
  191. compromise on strong security and possibility to use existing
  192. hardware. It still uses RC4 for the encryption like WEP, but with
  193. per-packet RC4 keys. In addition, it implements replay protection,
  194. keyed packet authentication mechanism (Michael MIC).
  195. Keys can be managed using two different mechanisms. WPA can either use
  196. an external authentication server (e.g., RADIUS) and EAP just like
  197. IEEE 802.1X is using or pre-shared keys without need for additional
  198. servers. Wi-Fi calls these "WPA-Enterprise" and "WPA-Personal",
  199. respectively. Both mechanisms will generate a master session key for
  200. the Authenticator (AP) and Supplicant (client station).
  201. WPA implements a new key handshake (4-Way Handshake and Group Key
  202. Handshake) for generating and exchanging data encryption keys between
  203. the Authenticator and Supplicant. This handshake is also used to
  204. verify that both Authenticator and Supplicant know the master session
  205. key. These handshakes are identical regardless of the selected key
  206. management mechanism (only the method for generating master session
  207. key changes).
  208. IEEE 802.11i / WPA2
  209. -------------------
  210. The design for parts of IEEE 802.11i that were not included in WPA has
  211. finished (May 2004) and this amendment to IEEE 802.11 was approved in
  212. June 2004. Wi-Fi Alliance is using the final IEEE 802.11i as a new
  213. version of WPA called WPA2. This includes, e.g., support for more
  214. robust encryption algorithm (CCMP: AES in Counter mode with CBC-MAC)
  215. to replace TKIP and optimizations for handoff (reduced number of
  216. messages in initial key handshake, pre-authentication, and PMKSA caching).
  217. wpa_supplicant
  218. --------------
  219. wpa_supplicant is an implementation of the WPA Supplicant component,
  220. i.e., the part that runs in the client stations. It implements WPA key
  221. negotiation with a WPA Authenticator and EAP authentication with
  222. Authentication Server. In addition, it controls the roaming and IEEE
  223. 802.11 authentication/association of the wlan driver.
  224. wpa_supplicant is designed to be a "daemon" program that runs in the
  225. background and acts as the backend component controlling the wireless
  226. connection. wpa_supplicant supports separate frontend programs and an
  227. example text-based frontend, wpa_cli, is included with wpa_supplicant.
  228. Following steps are used when associating with an AP using WPA:
  229. - wpa_supplicant requests the kernel driver to scan neighboring BSSes
  230. - wpa_supplicant selects a BSS based on its configuration
  231. - wpa_supplicant requests the kernel driver to associate with the chosen
  232. BSS
  233. - If WPA-EAP: integrated IEEE 802.1X Supplicant completes EAP
  234. authentication with the authentication server (proxied by the
  235. Authenticator in the AP)
  236. - If WPA-EAP: master key is received from the IEEE 802.1X Supplicant
  237. - If WPA-PSK: wpa_supplicant uses PSK as the master session key
  238. - wpa_supplicant completes WPA 4-Way Handshake and Group Key Handshake
  239. with the Authenticator (AP)
  240. - wpa_supplicant configures encryption keys for unicast and broadcast
  241. - normal data packets can be transmitted and received
  242. Building and installing
  243. -----------------------
  244. In order to be able to build wpa_supplicant, you will first need to
  245. select which parts of it will be included. This is done by creating a
  246. build time configuration file, .config, in the wpa_supplicant root
  247. directory. Configuration options are text lines using following
  248. format: CONFIG_<option>=y. Lines starting with # are considered
  249. comments and are ignored. See defconfig file for an example configuration
  250. and a list of available options and additional notes.
  251. The build time configuration can be used to select only the needed
  252. features and limit the binary size and requirements for external
  253. libraries. The main configuration parts are the selection of which
  254. driver interfaces (e.g., nl80211, wext, ..) and which authentication
  255. methods (e.g., EAP-TLS, EAP-PEAP, ..) are included.
  256. Following build time configuration options are used to control IEEE
  257. 802.1X/EAPOL and EAP state machines and all EAP methods. Including
  258. TLS, PEAP, or TTLS will require linking wpa_supplicant with OpenSSL
  259. library for TLS implementation. Alternatively, GnuTLS or the internal
  260. TLSv1 implementation can be used for TLS functionaly.
  261. CONFIG_IEEE8021X_EAPOL=y
  262. CONFIG_EAP_MD5=y
  263. CONFIG_EAP_MSCHAPV2=y
  264. CONFIG_EAP_TLS=y
  265. CONFIG_EAP_PEAP=y
  266. CONFIG_EAP_TTLS=y
  267. CONFIG_EAP_GTC=y
  268. CONFIG_EAP_OTP=y
  269. CONFIG_EAP_SIM=y
  270. CONFIG_EAP_AKA=y
  271. CONFIG_EAP_PSK=y
  272. CONFIG_EAP_SAKE=y
  273. CONFIG_EAP_GPSK=y
  274. CONFIG_EAP_PAX=y
  275. CONFIG_EAP_LEAP=y
  276. CONFIG_EAP_IKEV2=y
  277. Following option can be used to include GSM SIM/USIM interface for GSM/UMTS
  278. authentication algorithm (for EAP-SIM/EAP-AKA). This requires pcsc-lite
  279. (http://www.linuxnet.com/) for smart card access.
  280. CONFIG_PCSC=y
  281. Following options can be added to .config to select which driver
  282. interfaces are included.
  283. CONFIG_DRIVER_NL80211=y
  284. CONFIG_DRIVER_WEXT=y
  285. CONFIG_DRIVER_BSD=y
  286. CONFIG_DRIVER_NDIS=y
  287. Following example includes some more features and driver interfaces that
  288. are included in the wpa_supplicant package:
  289. CONFIG_DRIVER_NL80211=y
  290. CONFIG_DRIVER_WEXT=y
  291. CONFIG_DRIVER_BSD=y
  292. CONFIG_DRIVER_NDIS=y
  293. CONFIG_IEEE8021X_EAPOL=y
  294. CONFIG_EAP_MD5=y
  295. CONFIG_EAP_MSCHAPV2=y
  296. CONFIG_EAP_TLS=y
  297. CONFIG_EAP_PEAP=y
  298. CONFIG_EAP_TTLS=y
  299. CONFIG_EAP_GTC=y
  300. CONFIG_EAP_OTP=y
  301. CONFIG_EAP_SIM=y
  302. CONFIG_EAP_AKA=y
  303. CONFIG_EAP_PSK=y
  304. CONFIG_EAP_SAKE=y
  305. CONFIG_EAP_GPSK=y
  306. CONFIG_EAP_PAX=y
  307. CONFIG_EAP_LEAP=y
  308. CONFIG_EAP_IKEV2=y
  309. CONFIG_PCSC=y
  310. EAP-PEAP and EAP-TTLS will automatically include configured EAP
  311. methods (MD5, OTP, GTC, MSCHAPV2) for inner authentication selection.
  312. After you have created a configuration file, you can build
  313. wpa_supplicant and wpa_cli with 'make' command. You may then install
  314. the binaries to a suitable system directory, e.g., /usr/local/bin.
  315. Example commands:
  316. # build wpa_supplicant and wpa_cli
  317. make
  318. # install binaries (this may need root privileges)
  319. cp wpa_cli wpa_supplicant /usr/local/bin
  320. You will need to make a configuration file, e.g.,
  321. /etc/wpa_supplicant.conf, with network configuration for the networks
  322. you are going to use. Configuration file section below includes
  323. explanation fo the configuration file format and includes various
  324. examples. Once the configuration is ready, you can test whether the
  325. configuration work by first running wpa_supplicant with following
  326. command to start it on foreground with debugging enabled:
  327. wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -d
  328. Assuming everything goes fine, you can start using following command
  329. to start wpa_supplicant on background without debugging:
  330. wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
  331. Please note that if you included more than one driver interface in the
  332. build time configuration (.config), you may need to specify which
  333. interface to use by including -D<driver name> option on the command
  334. line. See following section for more details on command line options
  335. for wpa_supplicant.
  336. Command line options
  337. --------------------
  338. usage:
  339. wpa_supplicant [-BddfhKLqqtuvwW] [-P<pid file>] [-g<global ctrl>] \
  340. -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
  341. [-b<br_ifname> [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
  342. [-p<driver_param>] [-b<br_ifname>] ...]
  343. options:
  344. -b = optional bridge interface name
  345. -B = run daemon in the background
  346. -c = Configuration file
  347. -C = ctrl_interface parameter (only used if -c is not)
  348. -i = interface name
  349. -d = increase debugging verbosity (-dd even more)
  350. -D = driver name (can be multiple drivers: nl80211,wext)
  351. -f = Log output to default log location (normally /tmp)
  352. -g = global ctrl_interface
  353. -K = include keys (passwords, etc.) in debug output
  354. -t = include timestamp in debug messages
  355. -h = show this help text
  356. -L = show license (GPL and BSD)
  357. -p = driver parameters
  358. -P = PID file
  359. -q = decrease debugging verbosity (-qq even less)
  360. -u = enable DBus control interface
  361. -v = show version
  362. -w = wait for interface to be added, if needed
  363. -W = wait for a control interface monitor before starting
  364. -N = start describing new interface
  365. drivers:
  366. wext = Linux wireless extensions (generic)
  367. wired = wpa_supplicant wired Ethernet driver
  368. roboswitch = wpa_supplicant Broadcom switch driver
  369. bsd = BSD 802.11 support (Atheros, etc.)
  370. ndis = Windows NDIS driver
  371. In most common cases, wpa_supplicant is started with
  372. wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
  373. This makes the process fork into background.
  374. The easiest way to debug problems, and to get debug log for bug
  375. reports, is to start wpa_supplicant on foreground with debugging
  376. enabled:
  377. wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d
  378. If the specific driver wrapper is not known beforehand, it is possible
  379. to specify multiple comma separated driver wrappers on the command
  380. line. wpa_supplicant will use the first driver wrapper that is able to
  381. initialize the interface.
  382. wpa_supplicant -Dnl80211,wext -c/etc/wpa_supplicant.conf -iwlan0
  383. wpa_supplicant can control multiple interfaces (radios) either by
  384. running one process for each interface separately or by running just
  385. one process and list of options at command line. Each interface is
  386. separated with -N argument. As an example, following command would
  387. start wpa_supplicant for two interfaces:
  388. wpa_supplicant \
  389. -c wpa1.conf -i wlan0 -D nl80211 -N \
  390. -c wpa2.conf -i wlan1 -D wext
  391. If the interface is added in a Linux bridge (e.g., br0), the bridge
  392. interface needs to be configured to wpa_supplicant in addition to the
  393. main interface:
  394. wpa_supplicant -cw.conf -Dwext -iwlan0 -bbr0
  395. Configuration file
  396. ------------------
  397. wpa_supplicant is configured using a text file that lists all accepted
  398. networks and security policies, including pre-shared keys. See
  399. example configuration file, wpa_supplicant.conf, for detailed
  400. information about the configuration format and supported fields.
  401. Changes to configuration file can be reloaded be sending SIGHUP signal
  402. to wpa_supplicant ('killall -HUP wpa_supplicant'). Similarly,
  403. reloading can be triggered with 'wpa_cli reconfigure' command.
  404. Configuration file can include one or more network blocks, e.g., one
  405. for each used SSID. wpa_supplicant will automatically select the best
  406. betwork based on the order of network blocks in the configuration
  407. file, network security level (WPA/WPA2 is preferred), and signal
  408. strength.
  409. Example configuration files for some common configurations:
  410. 1) WPA-Personal (PSK) as home network and WPA-Enterprise with EAP-TLS as work
  411. network
  412. # allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
  413. ctrl_interface=/var/run/wpa_supplicant
  414. ctrl_interface_group=wheel
  415. #
  416. # home network; allow all valid ciphers
  417. network={
  418. ssid="home"
  419. scan_ssid=1
  420. key_mgmt=WPA-PSK
  421. psk="very secret passphrase"
  422. }
  423. #
  424. # work network; use EAP-TLS with WPA; allow only CCMP and TKIP ciphers
  425. network={
  426. ssid="work"
  427. scan_ssid=1
  428. key_mgmt=WPA-EAP
  429. pairwise=CCMP TKIP
  430. group=CCMP TKIP
  431. eap=TLS
  432. identity="user@example.com"
  433. ca_cert="/etc/cert/ca.pem"
  434. client_cert="/etc/cert/user.pem"
  435. private_key="/etc/cert/user.prv"
  436. private_key_passwd="password"
  437. }
  438. 2) WPA-RADIUS/EAP-PEAP/MSCHAPv2 with RADIUS servers that use old peaplabel
  439. (e.g., Funk Odyssey and SBR, Meetinghouse Aegis, Interlink RAD-Series)
  440. ctrl_interface=/var/run/wpa_supplicant
  441. ctrl_interface_group=wheel
  442. network={
  443. ssid="example"
  444. scan_ssid=1
  445. key_mgmt=WPA-EAP
  446. eap=PEAP
  447. identity="user@example.com"
  448. password="foobar"
  449. ca_cert="/etc/cert/ca.pem"
  450. phase1="peaplabel=0"
  451. phase2="auth=MSCHAPV2"
  452. }
  453. 3) EAP-TTLS/EAP-MD5-Challenge configuration with anonymous identity for the
  454. unencrypted use. Real identity is sent only within an encrypted TLS tunnel.
  455. ctrl_interface=/var/run/wpa_supplicant
  456. ctrl_interface_group=wheel
  457. network={
  458. ssid="example"
  459. scan_ssid=1
  460. key_mgmt=WPA-EAP
  461. eap=TTLS
  462. identity="user@example.com"
  463. anonymous_identity="anonymous@example.com"
  464. password="foobar"
  465. ca_cert="/etc/cert/ca.pem"
  466. phase2="auth=MD5"
  467. }
  468. 4) IEEE 802.1X (i.e., no WPA) with dynamic WEP keys (require both unicast and
  469. broadcast); use EAP-TLS for authentication
  470. ctrl_interface=/var/run/wpa_supplicant
  471. ctrl_interface_group=wheel
  472. network={
  473. ssid="1x-test"
  474. scan_ssid=1
  475. key_mgmt=IEEE8021X
  476. eap=TLS
  477. identity="user@example.com"
  478. ca_cert="/etc/cert/ca.pem"
  479. client_cert="/etc/cert/user.pem"
  480. private_key="/etc/cert/user.prv"
  481. private_key_passwd="password"
  482. eapol_flags=3
  483. }
  484. 5) Catch all example that allows more or less all configuration modes. The
  485. configuration options are used based on what security policy is used in the
  486. selected SSID. This is mostly for testing and is not recommended for normal
  487. use.
  488. ctrl_interface=/var/run/wpa_supplicant
  489. ctrl_interface_group=wheel
  490. network={
  491. ssid="example"
  492. scan_ssid=1
  493. key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
  494. pairwise=CCMP TKIP
  495. group=CCMP TKIP WEP104 WEP40
  496. psk="very secret passphrase"
  497. eap=TTLS PEAP TLS
  498. identity="user@example.com"
  499. password="foobar"
  500. ca_cert="/etc/cert/ca.pem"
  501. client_cert="/etc/cert/user.pem"
  502. private_key="/etc/cert/user.prv"
  503. private_key_passwd="password"
  504. phase1="peaplabel=0"
  505. ca_cert2="/etc/cert/ca2.pem"
  506. client_cert2="/etc/cer/user.pem"
  507. private_key2="/etc/cer/user.prv"
  508. private_key2_passwd="password"
  509. }
  510. 6) Authentication for wired Ethernet. This can be used with 'wired' or
  511. 'roboswitch' interface (-Dwired or -Droboswitch on command line).
  512. ctrl_interface=/var/run/wpa_supplicant
  513. ctrl_interface_group=wheel
  514. ap_scan=0
  515. network={
  516. key_mgmt=IEEE8021X
  517. eap=MD5
  518. identity="user"
  519. password="password"
  520. eapol_flags=0
  521. }
  522. Certificates
  523. ------------
  524. Some EAP authentication methods require use of certificates. EAP-TLS
  525. uses both server side and client certificates whereas EAP-PEAP and
  526. EAP-TTLS only require the server side certificate. When client
  527. certificate is used, a matching private key file has to also be
  528. included in configuration. If the private key uses a passphrase, this
  529. has to be configured in wpa_supplicant.conf ("private_key_passwd").
  530. wpa_supplicant supports X.509 certificates in PEM and DER
  531. formats. User certificate and private key can be included in the same
  532. file.
  533. If the user certificate and private key is received in PKCS#12/PFX
  534. format, they need to be converted to suitable PEM/DER format for
  535. wpa_supplicant. This can be done, e.g., with following commands:
  536. # convert client certificate and private key to PEM format
  537. openssl pkcs12 -in example.pfx -out user.pem -clcerts
  538. # convert CA certificate (if included in PFX file) to PEM format
  539. openssl pkcs12 -in example.pfx -out ca.pem -cacerts -nokeys
  540. wpa_cli
  541. -------
  542. wpa_cli is a text-based frontend program for interacting with
  543. wpa_supplicant. It is used to query current status, change
  544. configuration, trigger events, and request interactive user input.
  545. wpa_cli can show the current authentication status, selected security
  546. mode, dot11 and dot1x MIBs, etc. In addition, it can configure some
  547. variables like EAPOL state machine parameters and trigger events like
  548. reassociation and IEEE 802.1X logoff/logon. wpa_cli provides a user
  549. interface to request authentication information, like username and
  550. password, if these are not included in the configuration. This can be
  551. used to implement, e.g., one-time-passwords or generic token card
  552. authentication where the authentication is based on a
  553. challenge-response that uses an external device for generating the
  554. response.
  555. The control interface of wpa_supplicant can be configured to allow
  556. non-root user access (ctrl_interface_group in the configuration
  557. file). This makes it possible to run wpa_cli with a normal user
  558. account.
  559. wpa_cli supports two modes: interactive and command line. Both modes
  560. share the same command set and the main difference is in interactive
  561. mode providing access to unsolicited messages (event messages,
  562. username/password requests).
  563. Interactive mode is started when wpa_cli is executed without including
  564. the command as a command line parameter. Commands are then entered on
  565. the wpa_cli prompt. In command line mode, the same commands are
  566. entered as command line arguments for wpa_cli.
  567. Interactive authentication parameters request
  568. When wpa_supplicant need authentication parameters, like username and
  569. password, which are not present in the configuration file, it sends a
  570. request message to all attached frontend programs, e.g., wpa_cli in
  571. interactive mode. wpa_cli shows these requests with
  572. "CTRL-REQ-<type>-<id>:<text>" prefix. <type> is IDENTITY, PASSWORD, or
  573. OTP (one-time-password). <id> is a unique identifier for the current
  574. network. <text> is description of the request. In case of OTP request,
  575. it includes the challenge from the authentication server.
  576. The reply to these requests can be given with 'identity', 'password',
  577. and 'otp' commands. <id> needs to be copied from the the matching
  578. request. 'password' and 'otp' commands can be used regardless of
  579. whether the request was for PASSWORD or OTP. The main difference
  580. between these two commands is that values given with 'password' are
  581. remembered as long as wpa_supplicant is running whereas values given
  582. with 'otp' are used only once and then forgotten, i.e., wpa_supplicant
  583. will ask frontend for a new value for every use. This can be used to
  584. implement one-time-password lists and generic token card -based
  585. authentication.
  586. Example request for password and a matching reply:
  587. CTRL-REQ-PASSWORD-1:Password needed for SSID foobar
  588. > password 1 mysecretpassword
  589. Example request for generic token card challenge-response:
  590. CTRL-REQ-OTP-2:Challenge 1235663 needed for SSID foobar
  591. > otp 2 9876
  592. wpa_cli commands
  593. status = get current WPA/EAPOL/EAP status
  594. mib = get MIB variables (dot1x, dot11)
  595. help = show this usage help
  596. interface [ifname] = show interfaces/select interface
  597. level <debug level> = change debug level
  598. license = show full wpa_cli license
  599. logoff = IEEE 802.1X EAPOL state machine logoff
  600. logon = IEEE 802.1X EAPOL state machine logon
  601. set = set variables (shows list of variables when run without arguments)
  602. pmksa = show PMKSA cache
  603. reassociate = force reassociation
  604. reconfigure = force wpa_supplicant to re-read its configuration file
  605. preauthenticate <BSSID> = force preauthentication
  606. identity <network id> <identity> = configure identity for an SSID
  607. password <network id> <password> = configure password for an SSID
  608. pin <network id> <pin> = configure pin for an SSID
  609. otp <network id> <password> = configure one-time-password for an SSID
  610. passphrase <network id> <passphrase> = configure private key passphrase
  611. for an SSID
  612. bssid <network id> <BSSID> = set preferred BSSID for an SSID
  613. list_networks = list configured networks
  614. select_network <network id> = select a network (disable others)
  615. enable_network <network id> = enable a network
  616. disable_network <network id> = disable a network
  617. add_network = add a network
  618. remove_network <network id> = remove a network
  619. set_network <network id> <variable> <value> = set network variables (shows
  620. list of variables when run without arguments)
  621. get_network <network id> <variable> = get network variables
  622. save_config = save the current configuration
  623. disconnect = disconnect and wait for reassociate command before connecting
  624. scan = request new BSS scan
  625. scan_results = get latest scan results
  626. get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> = get capabilies
  627. terminate = terminate wpa_supplicant
  628. quit = exit wpa_cli
  629. wpa_cli command line options
  630. wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] [-a<action file>] \
  631. [-P<pid file>] [-g<global ctrl>] [command..]
  632. -h = help (show this usage text)
  633. -v = shown version information
  634. -a = run in daemon mode executing the action file based on events from
  635. wpa_supplicant
  636. -B = run a daemon in the background
  637. default path: /var/run/wpa_supplicant
  638. default interface: first interface found in socket path
  639. Using wpa_cli to run external program on connect/disconnect
  640. -----------------------------------------------------------
  641. wpa_cli can used to run external programs whenever wpa_supplicant
  642. connects or disconnects from a network. This can be used, e.g., to
  643. update network configuration and/or trigget DHCP client to update IP
  644. addresses, etc.
  645. One wpa_cli process in "action" mode needs to be started for each
  646. interface. For example, the following command starts wpa_cli for the
  647. default ingterface (-i can be used to select the interface in case of
  648. more than one interface being used at the same time):
  649. wpa_cli -a/sbin/wpa_action.sh -B
  650. The action file (-a option, /sbin/wpa_action.sh in this example) will
  651. be executed whenever wpa_supplicant completes authentication (connect
  652. event) or detects disconnection). The action script will be called
  653. with two command line arguments: interface name and event (CONNECTED
  654. or DISCONNECTED). If the action script needs to get more information
  655. about the current network, it can use 'wpa_cli status' to query
  656. wpa_supplicant for more information.
  657. Following example can be used as a simple template for an action
  658. script:
  659. #!/bin/sh
  660. IFNAME=$1
  661. CMD=$2
  662. if [ "$CMD" = "CONNECTED" ]; then
  663. SSID=`wpa_cli -i$IFNAME status | grep ^ssid= | cut -f2- -d=`
  664. # configure network, signal DHCP client, etc.
  665. fi
  666. if [ "$CMD" = "DISCONNECTED" ]; then
  667. # remove network configuration, if needed
  668. SSID=
  669. fi
  670. Integrating with pcmcia-cs/cardmgr scripts
  671. ------------------------------------------
  672. wpa_supplicant needs to be running when using a wireless network with
  673. WPA. It can be started either from system startup scripts or from
  674. pcmcia-cs/cardmgr scripts (when using PC Cards). WPA handshake must be
  675. completed before data frames can be exchanged, so wpa_supplicant
  676. should be started before DHCP client.
  677. For example, following small changes to pcmcia-cs scripts can be used
  678. to enable WPA support:
  679. Add MODE="Managed" and WPA="y" to the network scheme in
  680. /etc/pcmcia/wireless.opts.
  681. Add the following block to the end of 'start' action handler in
  682. /etc/pcmcia/wireless:
  683. if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
  684. /usr/local/bin/wpa_supplicant -B -c/etc/wpa_supplicant.conf \
  685. -i$DEVICE
  686. fi
  687. Add the following block to the end of 'stop' action handler (may need
  688. to be separated from other actions) in /etc/pcmcia/wireless:
  689. if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
  690. killall wpa_supplicant
  691. fi
  692. This will make cardmgr start wpa_supplicant when the card is plugged
  693. in.
  694. Dynamic interface add and operation without configuration files
  695. ---------------------------------------------------------------
  696. wpa_supplicant can be started without any configuration files or
  697. network interfaces. When used in this way, a global (i.e., per
  698. wpa_supplicant process) control interface is used to add and remove
  699. network interfaces. Each network interface can then be configured
  700. through a per-network interface control interface. For example,
  701. following commands show how to start wpa_supplicant without any
  702. network interfaces and then add a network interface and configure a
  703. network (SSID):
  704. # Start wpa_supplicant in the background
  705. wpa_supplicant -g/var/run/wpa_supplicant-global -B
  706. # Add a new interface (wlan0, no configuration file, driver=wext, and
  707. # enable control interface)
  708. wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan0 \
  709. "" wext /var/run/wpa_supplicant
  710. # Configure a network using the newly added network interface:
  711. wpa_cli -iwlan0 add_network
  712. wpa_cli -iwlan0 set_network 0 ssid '"test"'
  713. wpa_cli -iwlan0 set_network 0 key_mgmt WPA-PSK
  714. wpa_cli -iwlan0 set_network 0 psk '"12345678"'
  715. wpa_cli -iwlan0 set_network 0 pairwise TKIP
  716. wpa_cli -iwlan0 set_network 0 group TKIP
  717. wpa_cli -iwlan0 set_network 0 proto WPA
  718. wpa_cli -iwlan0 enable_network 0
  719. # At this point, the new network interface should start trying to associate
  720. # with the WPA-PSK network using SSID test.
  721. # Remove network interface
  722. wpa_cli -g/var/run/wpa_supplicant-global interface_remove wlan0
  723. Privilege separation
  724. --------------------
  725. To minimize the size of code that needs to be run with root privileges
  726. (e.g., to control wireless interface operation), wpa_supplicant
  727. supports optional privilege separation. If enabled, this separates the
  728. privileged operations into a separate process (wpa_priv) while leaving
  729. rest of the code (e.g., EAP authentication and WPA handshakes) into an
  730. unprivileged process (wpa_supplicant) that can be run as non-root
  731. user. Privilege separation restricts the effects of potential software
  732. errors by containing the majority of the code in an unprivileged
  733. process to avoid full system compromise.
  734. Privilege separation is not enabled by default and it can be enabled
  735. by adding CONFIG_PRIVSEP=y to the build configuration (.config). When
  736. enabled, the privileged operations (driver wrapper and l2_packet) are
  737. linked into a separate daemon program, wpa_priv. The unprivileged
  738. program, wpa_supplicant, will be built with a special driver/l2_packet
  739. wrappers that communicate with the privileged wpa_priv process to
  740. perform the needed operations. wpa_priv can control what privileged
  741. are allowed.
  742. wpa_priv needs to be run with network admin privileges (usually, root
  743. user). It opens a UNIX domain socket for each interface that is
  744. included on the command line; any other interface will be off limits
  745. for wpa_supplicant in this kind of configuration. After this,
  746. wpa_supplicant can be run as a non-root user (e.g., all standard users
  747. on a laptop or as a special non-privileged user account created just
  748. for this purpose to limit access to user files even further).
  749. Example configuration:
  750. - create user group for users that are allowed to use wpa_supplicant
  751. ('wpapriv' in this example) and assign users that should be able to
  752. use wpa_supplicant into that group
  753. - create /var/run/wpa_priv directory for UNIX domain sockets and control
  754. user access by setting it accessible only for the wpapriv group:
  755. mkdir /var/run/wpa_priv
  756. chown root:wpapriv /var/run/wpa_priv
  757. chmod 0750 /var/run/wpa_priv
  758. - start wpa_priv as root (e.g., from system startup scripts) with the
  759. enabled interfaces configured on the command line:
  760. wpa_priv -B -P /var/run/wpa_priv.pid wext:ath0
  761. - run wpa_supplicant as non-root with a user that is in wpapriv group:
  762. wpa_supplicant -i ath0 -c wpa_supplicant.conf
  763. wpa_priv does not use the network interface before wpa_supplicant is
  764. started, so it is fine to include network interfaces that are not
  765. available at the time wpa_priv is started. As an alternative, wpa_priv
  766. can be started when an interface is added (hotplug/udev/etc. scripts).
  767. wpa_priv can control multiple interface with one process, but it is
  768. also possible to run multiple wpa_priv processes at the same time, if
  769. desired.