# [SOLVED] Difficulties with wpa_supplicant

## hcaulfield57

I just got my Asus USB N-13 wifi adapter recognized by the kernel, but I'm having trouble actually connect to wifi with it. I'm pretty much a newb when it comes to networking, so please bear with me. The steps I've tried are as follows:

```

ifconfig wlan0 up # works

wpa_supplicant -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

# this hangs on 'Trying to associate with SSID 'my-ssid'

```

My wpa_supplicant.conf is as follows:

```

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

ap_scan=2

update_config=1

network={

   ssid="my-ssid"

        psk=my-hex-key

   proto=WPA

   key_mgmt=NONE

   priority=5

}

```

I have no idea what I should be doing.

----------

## BillWho

hcaulfield57,

I noticed from your other thread that you finally got your dongle working   :Very Happy: 

The next thing is to get the dongle matched up to your router, and get the syntax right.

Fashion your wpa_supplicant.conf like mine.

```
bill@laptop ~ $ cat /etc/wpa_supplicant/wpa_supplicant.conf 

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

update_config=1

network={

   ssid="myssid"

   psk="mypsk"

   proto=WPA2

   key_mgmt=WPA-PSK

   pairwise=CCMP TKIP-

   group=CCMP TKIP 

   id_str="gentoo-laptop"

}

My router is setup for wpa2 personal - wpa algorithims is TKIP+AES. Just make sure your info matches what the router is setup for.

```

Your line ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel  doesn't look kosher   :Wink: 

----------

## hcaulfield57

I've changed a few things around in the wpa_supplicant.conf and now I get the following upon issuing the command wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf

```

Trying to associate with 00:1c:10:40:5c:58 (SSID='my_network' freq=2437 MHz)

ioctl[SIOCSIWFREQ]: Device or resource busy

Association request to the driver failed

Associated with 00:1c:10:40:5c:58

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

CTRL-EVENT-DISCONNECTED bssid=00:1c:10:40:5c:58 reason=0  :? 

```

Thanks for the help in the previous thread too  :Smile:  Don't know why this has to be so difficult, I know this adapter works.

----------

## BillWho

hcaulfield57, 

This WPA: 4-Way Handshake failed - pre-shared key may be incorrect message looks like the SSID you're using doesn't match the router   :Confused: 

Is my-ssid the name entered in the router's WPA Shared Key field   :Question: 

----------

## hcaulfield57

 *BillWho wrote:*   

> hcaulfield57, 
> 
> This WPA: 4-Way Handshake failed - pre-shared key may be incorrect message looks like the SSID you're using doesn't match the router  
> 
> Is my-ssid the name entered in the router's WPA Shared Key field  

 

Sorry the name 'my_network' was just for example, not the actual name of the network. conf looks like this now

```

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

update_config=1

network={

   ssid="my_network"

   scan_ssid=1

   key_mgmt=WPA-PSK

   #psk="my_password"

   psk=hex_key # provided by wpa_passphrase

   proto=WPA

   group=TKIP

}

```

Tried switching around the ctrl_interface line like you suggested, but to no avail. With this setup I still get the same error as I indicated last post. 

iwlist wlan0 scan gives me:

```

Cell 02 - Address: 00:1C:10:40:5C:58

                    Channel:6

                    Frequency:2.437 GHz (Channel 6)

                    Quality=70/70  Signal level=-35 dBm  

                    Encryption key:on

                    ESSID:"my_network"

                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s

                              24 Mb/s; 36 Mb/s; 54 Mb/s

                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s

                    Mode:Master

                    Extra:tsf=00000025bc32ff1c

                    Extra: Last beacon: 58ms ago

                    IE: Unknown: 00066D617468636B

                    IE: Unknown: 010882848B962430486C

                    IE: Unknown: 030106

                    IE: Unknown: 2A0104

                    IE: Unknown: 2F0104

                    IE: Unknown: 32040C121860

                    IE: Unknown: DD09001018020015000000

                    IE: WPA Version 1

                        Group Cipher : TKIP

                        Pairwise Ciphers (1) : TKIP

                        Authentication Suites (1) : PSK

```

Thanks for bearing with me, networking (like I said) is not really my thing.

----------

## BillWho

hcaulfield57

I kinda figured my-ssid was just a placeholder - just wanted to make sure the router's key matched whatever you're actually using.

One thing I don't see in your scan is: IE: IEEE 802.11i/WPA2 Version 1

Check for these .config settings:

```
laptop linux # awk '/802/{if ($1 != "#") print}' /usr/src/linux/.config

CONFIG_CFG80211=m

CONFIG_CFG80211_DEFAULT_PS=y

CONFIG_CFG80211_WEXT=y

CONFIG_MAC80211=m

CONFIG_MAC80211_HAS_RC=y

CONFIG_MAC80211_RC_MINSTREL=y

CONFIG_MAC80211_RC_MINSTREL_HT=y

CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y

CONFIG_MAC80211_RC_DEFAULT="minstrel_ht"

CONFIG_MAC80211_LEDS=y

```

You can see my laptop card (ath9k) using cfg80211

```
laptop linux # lsmod|grep ath9k

ath9k                  95355  0 

ath9k_common            1881  1 ath9k

ath9k_hw              331655  2 ath9k_common,ath9k

ath                    14954  3 ath9k_common,ath9k,ath9k_hw

mac80211              366097  1 ath9k

cfg80211              168255  3 ath,ath9k,mac80211

```

You might want to check other dependents for your card too

```
laptop linux # modprobe --show-depends ath9k

insmod /lib/modules/3.6.11-gentoo/kernel/net/wireless/cfg80211.ko 

insmod /lib/modules/3.6.11-gentoo/kernel/net/mac80211/mac80211.ko 

insmod /lib/modules/3.6.11-gentoo/kernel/drivers/net/wireless/ath/ath.ko 

insmod /lib/modules/3.6.11-gentoo/kernel/drivers/net/wireless/ath/ath9k/ath9k_hw.ko 

insmod /lib/modules/3.6.11-gentoo/kernel/drivers/net/wireless/ath/ath9k/ath9k_common.ko 

insmod /lib/modules/3.6.11-gentoo/kernel/drivers/net/wireless/ath/ath9k/ath9k.ko blink=1 

```

----------

## hcaulfield57

 *BillWho wrote:*   

> 
> 
> Check for these .config settings:
> 
> ```
> ...

 

All of those options are compiled into my kernel. I kind of supposed it may have been a driver issue, because I feel it should be working. I don't know, maybe it was not meant to be.

----------

## hcaulfield57

Well, I thought I'd have a go with getting the wifi working on this computer. I finally managed to get things to work. Wifi connection is good, and I don't see any visible problems, other than my wifi dongle literally only works on one USB port on my computer. I know that sounds ridiculous, but I have checked every other port, and it's impossible to get it to work. This is frustrating, because the one that it does work on is in a non optimal location. Here is the relevant information that I can think of. 

wpa_supplicant.conf

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

network={

   ssid="<my_ssid>"

   scan_ssid=1

   proto=WPA

   key_mgmt=WPA-PSK

   pairwise=TKIP

   group=TKIP

   psk=<my_hexkey>

}

```

I can assure you this configuration works flawlessly, when the wifi dongle is plugged into that particular port. If it's plugged into any other port, it just hangs indefinitely on "SCANNING" (as revealed by `wpa_cli status`). It makes no sense to me why the wifi adapter would only work on one USB port. 

On other ports, I get a bunch of this with `wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -dd`

```

No suitable network found

Setting scan request: 5 sec 0 usec

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

Scan SSID - hexdump_ascii(len=6):

     6d 61 74 68 63 6b                                 <my_ssid>          

Starting AP scan for specific SSID(s)

Scan requested (ret=0) - scan timeout 30 seconds

EAPOL: Supplicant port status: Unauthorized

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

Wireless event: cmd=0x8b19 len=16

Received 0 bytes of scan results (0 BSSes)

BSS: Start scan result update 5

BSS: Expire BSS 1 due to no match in scan

BSS: Remove id 1 BSSID 00:1c:10:40:5c:58 SSID '<my_ssid>'

New scan results available

Selecting BSS from priority group 0

Try to find WPA-enabled AP

Try to find non-WPA AP

No suitable network found

Setting scan request: 5 sec 0 usec

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

Starting AP scan for wildcard SSID

Scan requested (ret=0) - scan timeout 30 seconds

EAPOL: Supplicant port status: Unauthorized

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

Wireless event: cmd=0x8b19 len=16

Received 0 bytes of scan results (0 BSSes)

BSS: Start scan result update 6

BSS: Expire BSS 2 due to no match in scan

BSS: Remove id 2 BSSID c0:3f:0e:72:e8:84 SSID 'Dillnet'

New scan results available

Selecting BSS from priority group 0

Try to find WPA-enabled AP

Try to find non-WPA AP

No suitable network found

Setting scan request: 5 sec 0 usec

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: Supplicant port status: Unauthorized

EAPOL: startWhen --> 0

EAPOL: disable timer tick

EAPOL: Supplicant port status: Unauthorized

Scan SSID - hexdump_ascii(len=6):

     6d 61 74 68 63 6b                                 <my_ssid>          

Starting AP scan for specific SSID(s)

Scan requested (ret=0) - scan timeout 30 seconds

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

Wireless event: cmd=0x8b19 len=16

Received 0 bytes of scan results (0 BSSes)

BSS: Start scan result update 7

New scan results available

Selecting BSS from priority group 0

Try to find WPA-enabled AP

Try to find non-WPA AP

No suitable network found

Setting scan request: 5 sec 0 usec

RX ctrl_iface - hexdump_ascii(len=6):

     53 54 41 54 55 53                                 STATUS          

Starting AP scan for wildcard SSID

Scan requested (ret=0) - scan timeout 30 seconds

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

Wireless event: cmd=0x8b19 len=16

Received 0 bytes of scan results (0 BSSes)

BSS: Start scan result update 8

New scan results available

Selecting BSS from priority group 0

Try to find WPA-enabled AP

Try to find non-WPA AP

No suitable network found

Setting scan request: 5 sec 0 usec

Scan SSID - hexdump_ascii(len=6):

     6d 61 74 68 63 6b                                 <my_ssid>          

Starting AP scan for specific SSID(s)

Scan requested (ret=0) - scan timeout 30 seconds

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

Wireless event: cmd=0x8b19 len=16

Received 0 bytes of scan results (0 BSSes)

BSS: Start scan result update 9

New scan results available

Selecting BSS from priority group 0

Try to find WPA-enabled AP

Try to find non-WPA AP

No suitable network found

Setting scan request: 5 sec 0 usec

^CCTRL-EVENT-TERMINATING - signal 2 received

Removing interface wlan0

No keys have been configured - skip key clearing

State: SCANNING -> DISCONNECTED

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

netlink: Operstate: linkmode=-1, operstate=5

EAPOL: External notification - portEnabled=0

EAPOL: Supplicant port status: Unauthorized

EAPOL: External notification - portValid=0

EAPOL: Supplicant port status: Unauthorized

EAPOL: External notification - EAP success=0

EAPOL: Supplicant port status: Unauthorized

wpa_driver_wext_set_countermeasures

No keys have been configured - skip key clearing

Cancelling scan request

Cancelling authentication timeout

netlink: Operstate: linkmode=0, operstate=6

```

dmesg has a bunch of this, I don't know if any of it is relevant. 

```

[  390.282159] rtl8192cu: MAC auto ON okay!

[  390.314873] rtl8192cu: Tx queue select: 0x05

[  390.688113] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

[  415.405801] wlan0: authenticate with 00:1c:10:40:5c:58

[  415.429819] wlan0: send auth to 00:1c:10:40:5c:58 (try 1/3)

[  415.446183] wlan0: authenticated

[  415.446195] rtl8192cu 2-1:1.0 wlan0: disabling HT/VHT due to WEP/TKIP use

[  415.446197] rtl8192cu 2-1:1.0 wlan0: disabling HT as WMM/QoS is not supported by the AP

[  415.446199] rtl8192cu 2-1:1.0 wlan0: disabling VHT as WMM/QoS is not supported by the AP

[  415.446536] wlan0: associate with 00:1c:10:40:5c:58 (try 1/3)

[  415.452677] wlan0: RX AssocResp from 00:1c:10:40:5c:58 (capab=0x411 status=0 aid=11)

[  415.452808] wlan0: associated

[  415.452816] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

[  425.447276] wlan0: deauthenticating from 00:1c:10:40:5c:58 by local choice (reason=3)

[  425.456637] cfg80211: Calling CRDA to update world regulatory domain

[  426.237105] wlan0: authenticate with 00:1c:10:40:5c:58

[  426.260842] wlan0: send auth to 00:1c:10:40:5c:58 (try 1/3)

[  426.460700] wlan0: send auth to 00:1c:10:40:5c:58 (try 2/3)

[  426.661504] wlan0: send auth to 00:1c:10:40:5c:58 (try 3/3)

[  426.722862] wlan0: authenticated

[  426.722874] rtl8192cu 2-1:1.0 wlan0: disabling HT/VHT due to WEP/TKIP use

[  426.722876] rtl8192cu 2-1:1.0 wlan0: disabling HT as WMM/QoS is not supported by the AP

[  426.722877] rtl8192cu 2-1:1.0 wlan0: disabling VHT as WMM/QoS is not supported by the AP

[  426.723444] wlan0: associate with 00:1c:10:40:5c:58 (try 1/3)

[  426.739967] wlan0: RX AssocResp from 00:1c:10:40:5c:58 (capab=0x411 status=0 aid=11)

[  426.740069] wlan0: associated

[  436.733070] wlan0: deauthenticating from 00:1c:10:40:5c:58 by local choice (reason=3)

[  436.742655] cfg80211: Calling CRDA for country: US

[  437.524020] wlan0: authenticate with 00:1c:10:40:5c:58

[  437.547856] wlan0: send auth to 00:1c:10:40:5c:58 (try 1/3)

[  437.748590] wlan0: send auth to 00:1c:10:40:5c:58 (try 2/3)

[  437.949393] wlan0: send auth to 00:1c:10:40:5c:58 (try 3/3)

[  438.150208] wlan0: authentication with 00:1c:10:40:5c:58 timed out

[  617.275524] rtl8192cu: MAC auto ON okay!

[  617.308238] rtl8192cu: Tx queue select: 0x05

[  617.681352] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

[  656.510183] rtl8192cu: MAC auto ON okay!

[  656.542897] rtl8192cu: Tx queue select: 0x05

[  656.921137] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

```

I suppose I can just deal with using the wifi dongle in one port, but it makes no sense to me why it won't work elsewhere. Any help would be much appreciated.

----------

## khayyam

 *BillWho wrote:*   

> Your line ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel doesn't look kosher

 

BillWho ... that method of defining the ctrl_interface and group is fine, I'm not sure if this is a recent change but the examples provided in the manpage for 2.0 define it this way.

hcaulfield57 ... as we discussed on #gentoo it has to be some issue with the slot itself, so powersave or USB3 vs USB2. So, more information in that regard might help to narrow down the issue. In may be a good idea to pastebin the output of the following when the card is in one or other slot:

```
# ip link set dev wlan0 up

# iw dev wlan0 get power_save

# lsusb -v
```

... also the following may provide some useful information about the driver

```
# modinfo rtl8192cu
```

As for the wpa_supplicant.conf and the network stanza, your first example used "ap_scan=2" and this was probably the cause of the initial error, you should generally avoid defining it (defaults to "1") unless you know the card requires it.

Looking at the output of the scan the following would be how I would define it:

```
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

update_config=1

network={

   ssid="my_network"

   bssid=00:1C:10:40:5C:58

   scan_freq=2437

   scan_ssid=0

   auth_alg=OPEN

   key_mgmt=WPA-PSK

   proto=WPA

   group=TKIP

   pairwise=TKIP

   psk=my_password # if your psk is the maximum char length (63) then don't quote the string.

}
```

Obviously the stanza is not the issue, but I thought I'd provide it anyhow :P

best ... khay

----------

## hcaulfield57

khayyam, thanks for the help previously on #gentoo and here. I've managed to get it working on any USB port on my computer at this point. I'm not sure what I did to fix that. I switched to nl80211 driver per your advice, and I also built the wifi driver as a module. However, the USB wifi adapter doesn't consistently work on every port, sometimes it wants to, other times it doesn't. I think it ultimately comes down to it just being a cheap shoddy wifi adapter. I will take this into consideration next time I buy a new one. 

EDIT: It seems like even when I can get it to work, it will continue to work after reboots, but not after full power downs. I'm not sure why. Perhaps it wants to be continually unplugged?  

EDIT: I did try the things you suggested, and I didn't notice any difference on various ports, and I can confirm it works on all the ports now, it just doesn't seem to be consistent. I'd still be willing to figure out how I can consistently make it work, but I'm running out of ideas. Maybe suggest another wifi usb? 

PS. I finally managed to fix my initramfs after several hours. I will probably learn how to make one once I get some time, so I don't have to rely on genkernel anymore.

----------

## khayyam

 *hcaulfield57 wrote:*   

> I've managed to get it working on any USB port on my computer at this point. I'm not sure what I did to fix that. I switched to nl80211 driver per your advice, and I also built the wifi driver as a module. However, the USB wifi adapter doesn't consistently work on every port, sometimes it wants to, other times it doesn't. I think it ultimately comes down to it just being a cheap shoddy wifi adapter. I will take this into consideration next time I buy a new one.

 

hcaulfield57 ... ok, good ... sort of. As I think I mentioned, I could find no mention of this Asus N-13 in any of the places where I'd normally look, and so you really never know what the specs are and what it expects of the firmware. For your next purchase I'd suggest looking through the list provided here.

 *hcaulfield57 wrote:*   

> EDIT: It seems like even when I can get it to work, it will continue to work after reboots, but not after full power downs. I'm not sure why. Perhaps it wants to be continually unplugged?

 

hmmm ... try blacklisting the module (/etc/modprobe.d/blacklist.conf) and loading it via preup()

/etc/conf.d/net.wlan0

```
preup() {

if [ -z "$(lsmod | awk '$1 ~/rtl8192cu/')" ] ; then

    modprobe rtl8192cu && sleep 0.5

fi
```

HTH & best ... khay

----------

## hcaulfield57

Thanks khayyam, as far as I am concerned everything 'works', even if it is a bit buggy. I'm going to mark this as solved. Thanks for all the help.

----------

