How to enable wireless on Ubuntu Server 18.04 via CLI?

Solution 1:

Let's amend your netplan file. From the terminal:

sudo nano /etc/netplan/01-netcfg.yaml

Amend the file to read:

network:
  version: 2
  renderer: networkd
  wifis:
    wlo1:
      dhcp4: true
      dhcp6: true
      access-points:
        "network_ssid_name":
          password: "**********"

Of course, substitue your network name and password. Note that both are enclosed in quotation marks ".

Netplan is quite strict about indentation and spacing; proofread carefully. Next, do:

sudo netplan generate
sudo netplan apply

Reboot and tell us if you connected:

ping -c3 www.ubuntu.com

If you get ping returns, you are all set.

Reference: https://netplan.io/examples