Netplan not connecting to hidden SSID Server 18.04.1 LTS

Solution 1:

Based on my reading of the official source code, this does NOT work yet. Netplan delegates WiFi connection to wpa_supplicant, but there are no provisions to emit the "scan_ssid=1" configuration line that wpa_supplicant expects.

See write_wpa_conf(): https://github.com/CanonicalLtd/netplan/blob/1265de994bd1ff5e1dad573d816b9201127206b3/src/networkd.c

However, by gross abuse of string escaping in the SSID name, I did get my connection to work.

"MYREALSSID\"\n  scan_ssid=1\n# \"hack!":
  password: "MYSSIDPASSWORD"

eventually becomes:

network={
  ssid="MYREALSSID"
  scan_ssid=1
# "hack!"
  psk="MYSSIDPASSWORD"
}

(Note the comment to swallow the open double quote).

Ubuntu bug: https://bugs.launchpad.net/netplan/+bug/1866100

Solution 2:

Since version 0.100 Netplan has been updated to now allow the hidden keyword.

As per the approved PR:

To check if you have the latest version check man netplan and look for the hidden (bool) keyword.

Suggested way:

man netplan | grep hidden

Example usage according to man page (hidden: true):

# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            dhcp4: true
            optional: true
            access-points:
                "SSID_name":
                    hidden: true
                    password: "WiFi_password"

Answer source: Documentation | Experience | Field Test