Connect to hiddn network Fedora Server 30 Raspberry 3 B+ at boot

I installed Fedora Server 30 on Raspberry 3 B+.
But I want to connect hidden wifi network and control my Server over SSH.
I try many ways to solve this problem, many of them failed. by nmcli it connects, but cannot start at boot.
I test nmtui too, but connect to the hidden network at boot failed and unsuccessful.
I try wpa_supplicant too but it failed too.
I want my server to connect to the hidden network at boot.

Hi mfaridi,

You will find that reconnecting to wifi is alot easier when the ssid isn’t hidden. If you think hidden wifi, means extra security; a google search for hidden wifi & security will show other wise. But if you are selfish like me and don’t want to share your 2nd (or only) internet line with your flat/house mates (or my case family) then systemd is your friend. Presuming NetworkManager has stored the password for your hidden wifi, then something like this should work:

/etc/systemd/system/hidden-wifi.service:

[Unit]
Description=Connect to hidden wifi
After=multi-user.target

[Service]
ExecStartPre=/usr/bin/sleep 10
ExecStart=/usr/bin/nmcli device wifi connect *Hidden Wifi*

[Install]
WantedBy=multi-user.target
  • Replace Hidden Wifi with the ssid of the hidden wifi network.

sudo systemctl enable hidden-wifi

Then reboot.

Should connect.

Thanks Tom.

But is the autoconnect property of the connection set to yes?

I go to /etc/systemd/system
and make hidden-wifi.service file there
and then I put these lines on it

[Unit]
Description=Connect to hidden wifi
After=multi-user.target

[Service]
ExecStartPre=/usr/bin/sleep 10
ExecStart=/usr/bin/nmcli device wifi connect faridi  123456789

[Install]
WantedBy=multi-user.target

ssid of my network is faridi and 123456789 is password of it.
after that I run this command
sudo systemctl enable hidden-wifi

and reboot
but nothing happen.
and my Fedora Server can not connect to hidden wifi network

Hi,

Whats the output of:

systemctl status hidden-wifi

It would be easier to for auto connect to work if nmcli/networkManger is storing the wifi password, so my systemd unit without the password entry should work if this is the case. If you feel the password is required please try:

Replace:

ExecStart=/usr/bin/nmcli device wifi connect faridi 123456789

With:

ExecStart=/usr/bin/nmcli device wifi connect faridi  password 123456789

Thanks Tom.

I change it to

ExecStart=/usr/bin/nmcli device wifi connect faridi  password 123456789

and reboot.
when I run
systemctl status hidden-wifi

I see this error

No network with SSID faridi found.

Hi,

Ok this occurring because the pi can’t see the hidden SSID, hopefully it just needs more time. Try increasing the sleep.

If that doesn’t work, consider @alciregi suggestion with nmcli & autoconnect, so something like:

sudo systemctl disable hidden-wifi.

nmcli connection add con-name WiFi type wifi ifname wlan0 ipv4.method auto autoconnect yes wifi.ssid faridi wifi-sec.psk 123456789

Thanks Tom.

when I run this command by sudo

nmcli connection add con-name WiFi type wifi ifname wlan0 ipv4.method auto autoconnect yes wifi.ssid faridi wifi-sec.psk 123456789

I see this error

802-11-wireless-security.key-mgmt: property is missing

Hi,

Sorry its bit a guess work, my headless servers are using wired networks. Hidden wifi I only use on my desktop. But I think adding the following to the command should do it:

wifi-sec.key-mgmt wpa-psk

Guessing your wifi network using wpa or wpa2.

If not see here:

https://developer.gnome.org/NetworkManager/stable/settings-802-11-wireless-security.html

key-mgmt row.

Thanks Tom.

I add
wifi-sec.key-mgmt wpa-psk
To last command and reboot, but nothing happen. My Fedora Server cannot connect to hidden wifi network.
I do not see error when I run than nmcli command.

That command can not run at boot.

Please start over, and possibly tell us in details what you do (which commands you issue and their output).
In addition, the systemd service as suggested by @tjdoyle is not necessary if the connection is properly configured: NetworkManager should take care of enabling and connecting to the wifi.
Ah! And an hidden SSID is exactly the same as a visible one, it simply doesn’t broadcast itself.

To list the configured connections: nmcli con show
To delete a connection: nmcli con delete <connectionname>

Then, what I suggest is: delete the eventually configured connections, and issue the following command (using your SSID and the wifi password).
This line works for me:
sudo nmcli con add con-name arbitraryConnectionName ifname wlan0 type wifi connection.autoconnect yes ssid yourSSID ipv4.method auto wifi-sec.key-mgmt wpa-psk wifi-sec.psk 'yourPassword'

1 Like

Hi,

Only suggested systemd as mfaridi had reported nmcli wasn’t working for them, it only became clear later on that the connection hadn’t been configured correctly with nmcli i.e password and autoconnect.

Thanks Tom.

1 Like

Yes yes :slight_smile: in fact, your suggestion is a valid workaround, but as I said: if the connection is properly configured NetworkManager should take care of enabling and connecting to the wifi.

Thanks.

1 Like

I test your command, but it does not work and after reboot my system can not connect to network.
When I run ifconfig, I see my wlan does not get an IP.
I delete all old connection too and try again.
But nothing happen.

Hi,

Please provide the output off:

nmcli connection show *Nameofwificonnection* | grep connection.autoconnect:

Nameofwificonnection should be listed with:

nmcli connection show

Thanks Tom.

I see these
Connection.autoconnect: yes
Connection.autoconnect-periority: 0
Connection.autoconnect-retries: -1 (default)
Connection.autoconnect-slaves: -1(default)

What doesn’t work? The command throws an error? Or it doesn’t connect?

I do not see error and it cannot connect to wifi network.

Even with sudo nmcli con up connectionName you are unable to connect?
In addition, it doesn’t connect or it doesn’t get an IP address?