How to configure wpa_supplicant in Ubuntu server 20.04

It is not necessary to manually configure wpa_supplicant.

Networking in recent Ubuntu server versions is managed by netplan. Check to see the name of your netplan file:

ls /etc/netplan

I will assume that the name of the file you found is 01-netcfg.yaml. Substitute your details here if not 01-netcfg.yaml.

We will amend the file to specify your details:

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

Change the file to read:

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

Please substitute your wireless interface name here instead of wlx----. Please note that the access point name and password are enclosed in quotation marks ". Spacing, indentation, etc. are crucial, please proofread carefully twice.

Save (Ctrl+o followed by Enter) and exit (Ctrl+x) the text editor nano. Follow with:

sudo netplan generate
sudo netplan apply

If you instead prefer a static IP address for the server, you can find the template here:

cat /usr/share/doc/netplan/examples/wireless.yaml