1

I have the wpa_supplicant filled out and ifdown and then ifup my wlan0 and it will connect, but if I accidentally typed a wrong password, it doesn't do anything obviously. Is there a way to test whether or not a wifi password will work before putting it into wpa_supplicant?

I'm looking for something that might look like this:

check ssid="[my_wifi]" with psk="[my_pass]"
6
  • How do you expect this "test" to work? The password kind of needs to be sent to the router to be validated Jan 28, 2017 at 0:29
  • Yeah, so isn't there a way to send a password to the router to see if it'll work before trying to connect? I am just trying to optimize the connection process is all. Jan 28, 2017 at 0:38
  • Just sending the password to the router is considered an attempt to connect Jan 28, 2017 at 0:39
  • How would you do that within Linux? Jan 28, 2017 at 2:02
  • What programming language? Jan 28, 2017 at 2:02

1 Answer 1

3

I think you got WiFi authentication wrong. In order to "test" your credentials, you will need to connect to it*.

In order to test it, I put the credentials somewhere (wpa_supplicant.conf usually), then use the command

sudo wpa_supplicant -D[driver] -c[file with the authentication stuff] -i[interface]

So my command would look like

sudo wpa_supplicant -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0

If the details are wrong, this line should show up:

wlan0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect

If it's correct, this should show up:

wlan0: WPA: Key negotiation completed with xx:xx:xx:xx:xx:xx [PTK=CCMP GTK=TKIP]
wlan0: CTRL-EVENT-CONNECTED - Connection to xx:xx:xx:xx:xx:xx completed [id=0 id_str=]

Note that wpa_supplicant may need to try a few times before it's successful, so 4-Way Handshake failed may appear multiple times even though the connection details are right.


This is an example of what to expect (I censored out some details)

pi@gateway0:~ $ sudo wpa_supplicant -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0
Successfully initialized wpa_supplicant
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCGIWSCAN]: Resource temporarily unavailable
ioctl[SIOCSIWSCAN]: Device or resource busy
wlan0: Trying to associate with XX:XX:XX:XX:XX:XX (SSID='Wifi name' freq=2442 MHz)
ioctl[SIOCSIWFREQ]: Device or resource busy
ioctl[SIOCSIWESSID]: Operation already in progress
wlan0: Association request to the driver failed
wlan0: Associated with XX:XX:XX:XX:XX:XX
wlan0: WPA: Invalid EAPOL-Key MIC when using TPTK - ignoring TPTK
wlan0: WPA: Could not verify EAPOL-Key MIC - dropping packet
wlan0: Authentication with XX:XX:XX:XX:XX:XX timed out.
wlan0: CTRL-EVENT-DISCONNECTED bssid=XX:XX:XX:XX:XX:XX reason=3 locally_generated=1
wlan0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="Wifi name" auth_failures=1 duration=10 reason=WRONG_KEY
ioctl[SIOCSIWSCAN]: Device or resource busy
wlan0: CTRL-EVENT-DISCONNECTED bssid=XX:XX:XX:XX:XX:XX reason=3 locally_generated=1
wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="Wifi name"
wlan0: Trying to associate with XX:XX:XX:XX:XX:XX (SSID='Wifi name' freq=2442 MHz)
ioctl[SIOCSIWFREQ]: Device or resource busy
wlan0: Association request to the driver failed
wlan0: Associated with XX:XX:XX:XX:XX:XX
wlan0: WPA: Key negotiation completed with XX:XX:XX:XX:XX:XX [PTK=CCMP GTK=TKIP]
wlan0: CTRL-EVENT-CONNECTED - Connection to XX:XX:XX:XX:XX:XX completed [id=0 id_str=]
1
  • 5 years later and I realized I forgot to put the footnote*. I meant to say with the asterisk that capturing a handshake then testing the password against it would also work (e.g. with the Aircrack suit).
    – Aloha
    Mar 26 at 5:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.