0

I have a Raspberry Py 4 with Ubuntu Server 20.04. I want to setup a WiFi connection on it. I have two WiFi networks (2.4 ghz and 5 ghz), both are hidden and have WPA2-Personal setup.

In my /etc/netpaln/50-cloud-init.yaml I have the following config:

network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    wifis:
        wlan0:
            optional: true
            access-points:
                "MY_HIDEN_SID":
                    password: "MY_PASSWORD"
            dhcp4: true

Unfortunately, network connection does not work. However, if I setup a mobile hotspot on my phone and change SID and password it connects successfully. So the reason must be in hidden network.

Question: How to connect Raspberry Pi 4 to a hidden WiFi network on Ubuntu Server 20.04?

UPDATE: It turns out there is an option in netplan to specify hidden networks. But it is available only from version 0.100. At the same time, it is not possible to identify which version is included into the 20.20 distribution (it is not the latest one) because netplan developers removed version information from the "netplan info" output.

UPDATE 2 This hack helped solve the issue.

2 Answers 2

0

netplan

.yaml files are very fussy with the formatting.

Use this .yaml, and keep the spacing, indentation, and no tabs exactly the same... edit in your SSID and password...

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      optional: true
  wifis:
    wlan0:
      #hidden: true # only in netplan 0.100
      dhcp4: true
      access-points:
        "MYREALSSID\"\n  scan_ssid=1\n# \"hack!":
          password: "MY_PASSWORD"

sudo netplan generate

sudo netplay apply

wpasupplicant

Ubuntu Server does not come with wpasupplicant installed, and it's required for wireless to work. We'll install it. A working ethernet connection is required, or a USB flash drive.

sudo apt-get update

sudo apt-get install wpasupplicant

reboot

Update #1:

A hack to get hidden networks to work is here.

8
  • Well, as I mentioned already, my configuration works well. The issue is it doesn't work with hidden networks. Sep 20, 2020 at 19:21
  • @SashaShpota You said "network connection does not work". Does it work when you remove optional: true from the wifis stanza? Did you install wpasupplicant?
    – heynnema
    Sep 20, 2020 at 19:22
  • If I remove optional: true it blocks the startup. No, I have not installed wpasupplicant. Sep 20, 2020 at 19:24
  • @SashaShpota optional: true only fails (for a specific amount of time) because the network connection can't be made. Install wpasupplicant and try again... as per my answer.
    – heynnema
    Sep 20, 2020 at 19:25
  • Turns out wpasupplicant was already a part of the distribution. Any other ideas? Sep 20, 2020 at 20:13
0

The correct format of the netplan file for hidden SSIDs on 20.04 is:

network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    wifis:
        wlan0:
            optional: true
            access-points:
                "MY_HIDEN_SID":
                    password: "MY_PASSWORD"
                    hidden: true
            dhcp4: true

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .