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
Philip Couling
Updated on September 18, 2022Comments
-
Philip Couling over 1 year
For esoteric reasons I have a server which only has WiFi access to the network.
By copying the necessary dpkg files on a removable drive I've managed to install wpa_supplicant.
The thing that's bugging me is that on other distributions configuring it can be done by editing
/etc/wpa_supplicant/wpa_supplicant.conf
. But this doesn't work on Ubuntu because the systemd service file starts up wpa_supplicant without specifying a configuration file. There is no-c
specified in its arguments.Even the Ubuntu man page says the most common way to start it is by specifying a config file...
In most common cases, wpa_supplicant is started with:
wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
Because this is a server there is no GUI installed and I'm not using network manager (AFAIK)
I have of course confirmed that shutting down the systemd service and manually starting the Daemon from the command line will work. And I can of course modify the .service file. But this feels like the wrong solution.
Can anyone tell me how I am supposed to configure wpa_supplicant on Ubuntu server?
-
N0rbert almost 4 yearsLooks a bit difficult. Why do you not want to use NetworkManager with
nmtui
? -
Philip Couling almost 4 yearsHonestly I've never knowingly used network manager on a server before and have always considered it a desktop thing. I've always just configured interfaces manually. Are you suggesting that wpa_supplicant has been setup to only communicate with network manager by default?
-
N0rbert almost 4 yearsIf I understand this correctly - the wpa_supplicant is used on embedded devices with limited resources (like cheap routers with OpenWRT-based firmware), so installation of NetworkManager is not possible here. But in your case - the resources are not limited and you can simply install NetworkManager here, I think.
-
-
Philip Couling almost 4 yearsAh. I knew I was missing something. Out of interest, do you know which version of Ubuntu server started using netplan by default?
-
Philip Couling almost 4 yearsJust to be clear does netplan use wpa_supplicant or can I remove that now?
-
chili555 almost 4 yearsUbuntu 17.10 started using netplan and you should retain wpa_supplicant.
-
N0rbert almost 4 years@chili555 great! Where the official documentation for your method may be found? I can't find anything related on help.ubuntu.com . But the wiki.ubuntu.com/Netplan/Design seems to be correct place, but provides small amount of details.
-
chili555 almost 4 yearsPlease check here: netplan.io You can find many templates in
/usr/share/doc/netplan/examples/
-
iambr over 2 yearseven works on default ubuntu!
-
Eric Platon over 2 yearsExtra note:
wpa_supplicant
is implicitly required, as confirmed in the comments. Without it installed, this solution and others "work", but no connection still. I was setting up a vanilla minimal 18.04 LTS on a machine without WPA device, andwpa_supplicant
was not installed. For the solution here to actually work, installing it was necessary (e.g.sudo apt-get install wpa_supplicant
). At this point Netplan and the backends do not seem to report the missing assumption. -
chili555 over 2 years@EricPlaton Correct. By default, Ubuntu server edition does not include the required packages wpa_supplicant and wireless-tools. However, since the original question was concerned with configuring wpa_supplicant. I felt safe to assume that it was previously installed.