0

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]"

closed as off-topic by Milliways, goobering, Jacobm001, joan, Dmitry Grigoryev Feb 7 '17 at 14:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Milliways, goobering, Jacobm001, joan
If this question can be reworded to fit the rules in the help center, please edit the question.

  • How do you expect this "test" to work? The password kind of needs to be sent to the router to be validated – Mohammad Ali Jan 28 '17 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. – DJSweetness Jan 28 '17 at 0:38
  • Just sending the password to the router is considered an attempt to connect – Mohammad Ali Jan 28 '17 at 0:39
  • How would you do that within Linux? – DJSweetness Jan 28 '17 at 2:02
  • What programming language? – Mohammad Ali Jan 28 '17 at 2:02
1

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.

*I know methods that don't need to connect to the hotspot, but they're advanced and are usually reserved for WiFi hackers


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=]

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