# Network Manager intermittently not reading WiFi PSK

## baldignoramus

Hi Forum. Gentoo Newbie here. My NetworkManager is behaving strangely.  Upon logging in  and using 

```
$ nmcli c up My-Primary-SSID-2.4G 

Passwords or encryption keys are required to access the wireless network 'My-Primary-SSID-2.4G'.

Warning: password for '802-11-wireless-security.psk' not given in 'passwd-file' and nmcli cannot ask without '--ask' option.

Error: Connection activation failed: Secrets were required, but not provided

```

However, upon checking /etc/NetworkManager/system-connections/My-Primary-SSID-2.4G, the psk is available!

```

[wifi-security]

key-mgmt=wpa-psk

psk=Primary24GPSKPassword

```

The same command works if I 

Try it a few times. Sometimes, it works after about 6-7 times --OR--

If I first connect to another SSID and then connect back to My-Primary-SSID-2.4G , it works. 

I also tried turning off 802-11-wireless.mac-address-randomization after reading the Arch Wiki. That did not seem to make any difference. Switching from NetworkManager back to dhcpcd+wpa_suppilcant  seems to work without any hitches.  I did make sure to turn off dhcpcd before turning on NetworkManager again.

I think I have reached limits of my knowledge. Please can someone help me ?

----------

## alamahant

Please try this

```

nmcli con show

nmcli con del <delete-all-connections>

nmcli con add autoconnect yes type wifi con-name <your-ssid> ifname wlan0(or the particular name you have) ssid <your-ssid> ip4 192.168.1.56/24 gw4 192.168.1.1

nmcli con mod <your-ssid> ipv4.dns <your-dns> ipv4.method manual

nmcli con mod <your-ssid> wifi-sec.key-mgmt wpa-psk

nmcli con mod <your-ssid> wifi-sec.psk <your-passwd>

nmcli con up <your-ssid>

```

It goes without saying that if you are using NM you do not need to use netifrc.Better if you didnt.

If you are then delete all net.<iface> symlinks in /etc/init.d and disable them with rc-update.Or AT LEAST disable them.

BUT is it maybe a driver issue?a firmware issue?One can never be too certain.....

Please post the output of

```

lspci -v

equery u networkmanager

```

and....

Welcome to Gentoo!

 :Smile: 

----------

## baldignoramus

Thanks alamahant! So far I like what I am seeing with Gentoo -- apart from build times for large applications like firefox and libreoffice   :Surprised:  , but they are quite large code-bases. 

I have deleted all the other connections as you suggested.  When connecting the same error occurs i.e. 

```
$ nmcli c up My-Primary-SSID-2.4G

Passwords or encryption keys are required to access the wireless network 'My-Primary-SSID-2.4G'.

Warning: password for '802-11-wireless-security.psk' not given in 'passwd-file' and nmcli cannot ask without '--ask' option.

Error: Connection activation failed: Secrets were required, but not provided

```

As far as I am aware, netifrc is not enabled. However, I believe openRC is  built with  USE=netifrc by default. 

The extract from the lspci command is: 

```
 $ lspci -vk

02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0e)

        Subsystem: Lenovo RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller

        Flags: bus master, fast devsel, latency 0, IRQ 38, IOMMU group 11

        I/O ports at 2400 [size=256]

        Memory at fd714000 (64-bit, non-prefetchable) [size=4K]

        Memory at fd700000 (64-bit, non-prefetchable) [size=16K]

        Capabilities: [40] Power Management version 3

        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+

        Capabilities: [70] Express Endpoint, MSI 01

        Capabilities: [b0] MSI-X: Enable+ Count=4 Masked-

        Capabilities: [d0] Vital Product Data

        Capabilities: [100] Advanced Error Reporting

        Capabilities: [140] Virtual Channel

        Capabilities: [160] Device Serial Number 01-00-00-00-68-4c-e0-00

        Capabilities: [170] Latency Tolerance Reporting

        Capabilities: [178] L1 PM Substates

        Kernel driver in use: r8169

        Kernel modules: r8169

03:00.0 Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a)

        Subsystem: Intel Corporation Wi-Fi 6 AX200

        Physical Slot: 0

        Flags: bus master, fast devsel, latency 0, IRQ 98, IOMMU group 12

        Memory at fd600000 (64-bit, non-prefetchable) [size=16K]

        Capabilities: [c8] Power Management version 3

        Capabilities: [d0] MSI: Enable- Count=1/1 Maskable- 64bit+

        Capabilities: [40] Express Endpoint, MSI 00

        Capabilities: [80] MSI-X: Enable+ Count=16 Masked-

        Capabilities: [100] Advanced Error Reporting

        Capabilities: [14c] Latency Tolerance Reporting

        Capabilities: [154] L1 PM Substates

        Kernel driver in use: iwlwifi

        Kernel modules: iwlwifi

```

NetworkManger has been compiled with USE flags 

```
$ equery u net-misc/networkmanager

[ Legend : U - final flag setting for installation]

[        : I - package is installed with flag     ]

[ Colors : set, unset                             ]

 * Found these USE flags for net-misc/networkmanager-1.30.4:

 U I

 - - abi_x86_32         : 32-bit (x86) libraries

 - - audit              : Enable support for Linux audit subsystem using sys-process/audit

 + + bluetooth          : Enable Bluetooth Support

 - - connection-sharing : Use net-dns/dnsmasq and net-firewall/iptables for connection sharing

 - - dhclient           : Use dhclient from net-misc/dhcp for getting ip

 - - dhcpcd             : Use net-misc/dhcpcd for getting ip

 + + elogind            : Use sys-auth/elogind for session tracking

 - - gnutls             : Prefer net-libs/gnutls as SSL/TLS provider (ineffective with USE=-ssl)

 + + introspection      : Add support for GObject based introspection

 - - iwd                : Use net-wireless/iwd instead of net-wireless/wpa_supplicant for wifi support by default

 + + modemmanager       : Enable support for mobile broadband devices using net-misc/modemmanager

 + + ncurses            : Add ncurses support (console display library)

 + + nss                : Use dev-libs/nss for cryptography

 - - ofono              : Use net-misc/ofono for telephony support.

 - - ovs                : Enable OpenVSwitch support 

 + + ppp                : Enable support for mobile broadband and PPPoE connections using net-dialup/ppp

 - - resolvconf         : Use net-dns/openresolv for managing DNS information in /etc/resolv.conf. Generally, a

                          symlink to /run/NetworkManager/resolv.conf is simpler. On systems running

                          systemd-resolved, disable this flag and create a symlink to

                          /run/systemd/resolve/stub-resolv.conf.

 - - systemd            : Enable use of systemd-specific libraries and features like socket activation or session

                          tracking

 - - teamd              : Enable Teamd control support 

 - - test               : Enable dependencies and/or preparations necessary to run tests (usually controlled by

                          FEATURES=test but can be toggled independently)

 - - vala               : Enable bindings for dev-lang/vala

 + + wext               : Enable support for the deprecated Wext (Wireless Extensions) API; needed for some older

                          drivers (e.g. ipw2200, ndiswrapper)

 + + wifi               : Enable support for wifi and 802.1x security 

```

----------

## alamahant

Do you have these in your .config

```

CONFIG_IWLWIFI=m

CONFIG_IWLWIFI_LEDS=y

CONFIG_IWLWIFI_OPMODE_MODULAR=y

# CONFIG_IWLWIFI_BCAST_FILTERING is not set

CONFIG_IWLWIFI_DEBUG=y

CONFIG_IWLWIFI_DEBUGFS=y

CONFIG_IWLWIFI_DEVICE_TRACING=y

```

Make sure 

CONFIG_IWLWIFI

is configured as module =m not =y

Also plz 

```

emerge -av linux-firmware 

```

PROBABLY THESE ARE NOT THE ISSUE HERE but just check just in case.

Does restarting NM 2-3 times solve the issue maybe?

I am afraid NM is looking for these

```

[ebuild  N     ] gnome-base/gnome-keyring-40.0::gentoo  USE="caps filecaps pam ssh-agent (-selinux) -test" 0 KiB

[ebuild  N     ] app-crypt/libsecret-0.20.4::gentoo  USE="crypt introspection vala -gtk-doc -test" ABI_X86="(64) -32 (-x32)" 518 KiB

```

----------

## Jaglover

```
CONFIG_IWLWIFI_DEBUG=y

CONFIG_IWLWIFI_DEBUGFS=y

CONFIG_IWLWIFI_DEVICE_TRACING=y
```

This will enlarge the driver and is useful only if you really work on debugging the driver. As all other CONFIG_DEBUG options in kernel it should be turned off.

```
CONFIG_IWLDVM 

CONFIG_IWLMVM
```

One of these should be turned on, depending on what kind of firmware is needed. It is safe to have both.

----------

## baldignoramus

 *alamahant wrote:*   

> Do you have these in your .config
> 
> ```
> 
> CONFIG_IWLWIFI=m
> ...

 

All these options (apart from CONFIG_IWLWIFI_DEVICE_TRACING) are turned on. CONFIG_IWLWIFI is configured as a module. I chickened out for building the kernel and let genkernel do the kernel configuration rather than do it myself. genkernel seems to have defaulted to making DEBUG available.  also linux-firmware had already been emerge'd.

 *alamahant wrote:*   

> Does restarting NM 2-3 times solve the issue maybe?

 

Not satisfactorily. After a few times (~ 6-7), it seems to be able to connect. However, the connection sometimes gets dropped after a while. 

 *alamahant wrote:*   

> 
> 
> I am afraid NM is looking for these
> 
> ```
> ...

 

I had the KDE profile (default/linux/amd64/17.1/desktop/plasma (stable)) selected, so these two have not been merged into the system. 

 *Jaglover wrote:*   

> 
> 
> ```
> 
> CONFIG_IWLWIFI_DEBUG=y
> ...

 

Both  CONFIG_IWLDVM and CONFIG_IWLMVM are turned on as modules in my kernel config.  

```
CONFIG_IWLWIFI=m

CONFIG_IWLWIFI_LEDS=y

CONFIG_IWLDVM=m

CONFIG_IWLMVM=m

CONFIG_IWLWIFI_OPMODE_MODULAR=y

# CONFIG_IWLWIFI_BCAST_FILTERING is not set

#

# Debugging Options

#

CONFIG_IWLWIFI_DEBUG=y

CONFIG_IWLWIFI_DEBUGFS=y

# CONFIG_IWLWIFI_DEVICE_TRACING is not set

# end of Debugging Options

```

The Intel AX200 chipset that I have, seems to have loaded iwlmvm

```

$ lsmod | grep -i iwl

iwlmvm                479232  0

mac80211             1097728  1 iwlmvm

iwlwifi               344064  1 iwlmvm

cfg80211              974848  3 iwlmvm,iwlwifi,mac80211

```

----------

## baldignoramus

I think I have solved the issue. I had added 'wpa_supplicant' to openRC to help make the install process smoother over multiple reboot sessions. After I installed and added NetworkManager to openRC, I forgot to remove wpa_supplicant.   :Embarassed: 

This was causing two wpa_supplicant sessions to run :

One which I had manually added to openRC 

The wpa_supplicant instance loaded as a dependency of Network Manager

Thanks for all the pointers and help!

----------

