README 36 KB

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