# [solved] How to get wifi connection at boot with systemd?

## urcindalo

Hi and thanks for reading this. I'm sure this has had to be asked before, but I couldn't find any related thread.

I run a stable box with systemd, and after boot I login into KDE and then it automatically connects to my WiFi network. However, I'd like to get online through my wifi connection before logging into KDE, just in case I have to restart my box remotely.

After boot, but before login into KDE, I see this:

```
 $ systemctl status NetworkManager

■ NetworkManager.service - Network Manager

   Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: disabled)

   Active: active (running) since Wed 2019-10-16 18:53:42 CEST; 1min 24s ago

     Docs: man:NetworkManager(8)

 Main PID: 420 (NetworkManager)

   CGroup: /system.slice/NetworkManager.service

           └─420 /usr/sbin/NetworkManager --no-daemon

oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7028] sup-iface[0x555978046000,wlan0]: wps: type pbc start...

oct 16 18:53:51 Urci NetworkManager[420]: <warn>  [1571244831.7034] device (wlan0): no secrets: No agents were available for this request.

oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7035] device (wlan0): state change: need-auth -> failed (reason 'no-secrets', sys-iface-state: 'managed')

oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7039] manager: NetworkManager state is now DISCONNECTED

oct 16 18:53:51 Urci NetworkManager[420]: <warn>  [1571244831.7042] device (wlan0): Activation: failed for connection 'Urcindalo_Plus'

oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7044] device (wlan0): state change: failed -> disconnected (reason 'none', sys-iface-state: 'managed')

oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7101] device (wlan0): set-hw-addr: set MAC address to F2:D9:22:F3:A6:59 (scanning)

oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7250] device (wlan0): supplicant interface state: disabled -> inactive

oct 16 18:53:51 Urci NetworkManager[420]: <info>  [1571244831.7255] device (p2p-dev-wlan0): supplicant management interface state: disabled -> inactive

oct 16 18:53:55 Urci NetworkManager[420]: <info>  [1571244835.4393] manager: startup complete
```

As you can see, it tries to connect to my WiFi network but fails.

I guess it is a matter of NetworkManager not finding the password. Am I right?

After I login into KDE, NetworkManager connects and:

```
$ systemctl status NetworkManager

● NetworkManager.service - Network Manager

   Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: disabled)

   Active: active (running) since Wed 2019-10-16 18:53:42 CEST; 4min 7s ago

     Docs: man:NetworkManager(8)

 Main PID: 420 (NetworkManager)

   CGroup: /system.slice/NetworkManager.service

           ├─ 420 /usr/sbin/NetworkManager --no-daemon

           └─2372 /sbin/dhcpcd -B -K -L -A -G -c /usr/libexec/nm-dhcp-helper -4 -h Urci wlan0

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4811] dhcp4 (wlan0):   nameserver '80.58.61.254'

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4811] dhcp4 (wlan0): state changed expire -> bound

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4825] device (wlan0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4834] device (wlan0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4836] device (wlan0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed>

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.4842] manager: NetworkManager state is now CONNECTED_LOCAL

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.6809] manager: NetworkManager state is now CONNECTED_SITE

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.6811] policy: set 'Urcindalo_Plus' (wlan0) as default for IPv4 routing and DNS

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.9821] device (wlan0): Activation: successful, device activated.

oct 16 18:57:37 Urci NetworkManager[420]: <info>  [1571245057.9826] manager: NetworkManager state is now CONNECTED_GLOBAL
```

So, what could I do so that Wifi connects at boot, before logging into KDE?Last edited by urcindalo on Fri Oct 18, 2019 7:10 am; edited 1 time in total

----------

## eccerr0r

For NetworkManager,  go into nm-applet and edit connections.  Then in the General options, mark the connections that are acceptable for connecting upon boot both as "Connect Automatically" and "All users may connect to this network" (apparently root counts as a user on boot that NetworkManager will honor as any other user.  This will also copy the authentication keys into the system for any user, including root, to use.)

It should now try to connect when NetworkManager starts, at least this seems to work on both my OpenRC and systemd NetworkManager boxes.

I've not needed to edit any of the NetworkManager saved files to hack in the authentication keys.

----------

## urcindalo

 *eccerr0r wrote:*   

> For NetworkManager,  go into nm-applet and edit connections.  Then in the General options, mark the connections that are acceptable for connecting upon boot both as "Connect Automatically" and "All users may connect to this network" (apparently root counts as a user on boot that NetworkManager will honor as any other user.  This will also copy the authentication keys into the system for any user, including root, to use.)

 

Thanks for your help. Both options were already marked.

There's a priority selection, currently at 0, just next to "Connect Automatically". Should I change this? What do control the possible values?

----------

## eccerr0r

Zero is fine for the priority.  This is for if you have multiple possible wifi hotspots, it will choose based on priority if more than one can be authenticated.

Something's not synced up for you it seems.  You might want to try disable each of the options, save it, and reenable them.  Sometimes there's some state that doesn't get saved properly.

----------

## GrandeGrabois

Just a wild guess, but maybe you could try setting this connection directly with nmcli from the terminal. Perhaps there is something about KDE storing passwords via KWallet that makes it unaccessible during boot

----------

## urcindalo

Thanks everyone for your suggestions.

 *eccerr0r wrote:*   

> Something's not synced up for you it seems.  You might want to try disable each of the options, save it, and reenable them.  Sometimes there's some state that doesn't get saved properly.

 

I tried this, to no avail.

 *GrandeGrabois wrote:*   

> Just a wild guess, but maybe you could try setting this connection directly with nmcli from the terminal. Perhaps there is something about KDE storing passwords via KWallet that makes it unaccessible during boot

 

I had already tried this, before posting here.

However, I've solved it. To make a long story short, my .nmconnection file in /etc/NetworkManager/system-connections lacked the password info and the NetworkManager KDE widget was not storing it in that file. To have the password stored, I tried several ways (I didn't edit the file manually since I couldn't find the correct syntax). In the end, it seems that running nm-connection-editor as root made the trick, altough it constantly was telling me that dconf couldn't write the file. However, when I looked at /etc/NetworkManager/system-connections/MyWiFi.nmconnection, there it was:

```
[wifi-security]

key-mgmt=wpa-psk

psk=YoUrPaSsWoRd#1234
```

So, I guess it all lreduces to include the above lines in the corresponding .nmconnection file.

I hope this helps other people.

----------

## yuri_sevatz

If anyone is still hitting this, I have noticed that the latest Gnome (Gnome 3.34) correctly places your wifi-password in the wifi-security section,  if you first:

1. uncheck "Make this connection available to others", click Apply

2. re-check "Make this connection available to others" click Apply.

It looks like it's just not migrating the config from older versions of gnome, until you do these steps.

----------

## gasdiver

 *yuri_sevatz wrote:*   

> If anyone is still hitting this, I have noticed that the latest Gnome (Gnome 3.34) correctly places your wifi-password in the wifi-security section,  if you first:
> 
> 1. uncheck "Make this connection available to others", click Apply
> 
> 2. re-check "Make this connection available to others" click Apply.
> ...

 

I'm usually a lurker and wasn't intending to register here in the forum, but I registered just to say thanks. Your solution solved my problem,  Cheers!

----------

