0

I have Ubuntu server on an old laptop which I built at home, connected to my home Wi-Fi.
This is a portable server and during the course of the day I change the location and I need to connect to a new Wi-Fi SSID from the command line.

All of the options I can find suggest using apt to load some new software to access some functionality.

Problem is apt is not going to play untill I have a Wi-Fi connection.

Now the SSID and password has to be stored either in grub or somewhere in the current file structure.

It's ironic: I have a 4G Wi-Fi hotspot that I can use anywhere if I can only get the server to see it.

I need the solution to be command line, without a current Wi-Fi connection and it has to be possible hey you can do it with a couple of clicks from a GUI.

OK if the solution is in a text file, it makes the server easy to hack on the network but it's my network and it's only available when I am online.

If push comes to shove I will do a full instalation using the 4G hotspot but I am only going to have to change this when I am on my home Wi-Fi or conected to some other remote Wi-Fi.

rzickler
  • 187
  • 1
  • 2
  • 8

2 Answers2

1

Without network connectivity, you could follow these steps. If your Wifi card is already working and if nmcli is already install, go to step 5.

  1. Retrieve what packages APT would like to download. To do so, run sudo apt install .... It displays the packages which need to be installed (which includes the needed dependencies). Of course, it will fail, because you have no network yet. The only goal of this step is to get the package list. You might fear to have tons of packages to manually download, but in practice, you only need:
  • possibly, the firmware package supporting your Wi-fi card (which has usually no dependencies)
  • network-manager to get nmcli (which is hopefully already installed).
  1. Download each corresponding DEB file from [packages.ubuntu.com].

  2. Copy the DEB file into /var/cache/apt/archives. For example if your DEB files are stored in a USB stick mounted in /media/usb, you would run:

sudo cp /media/usb/*deb /var/cache/apt/archives
  1. Run sudo apt install .... As the packages are already in the cache, APT won't complain about the network.

  2. Follow the steps listed in AU: How do I connect to a WiFi network using nmcli? to configure your Wi-fi connection.

0

The network configuration file on Ubuntu is a YAML file located in the /etc/netplan directory. The default name of the configuration file is 00-installer-config.yaml

Step 1: open the network configuration file using your favorite text editor, replace the contents of the configuration file with the following template. Make sure you change the following details:

  • Wi-Fi interface name: Replace the interface name wlp0s20f3, with the correct Wi-Fi interface name you obtained by the following ls command to list all your network interfaces: ls -l /sys/class/net. Wi-Fi interface cards start with the letter w. In this case, the Wi-Fi interface card name is wlp0s20f3. Your system will probably have a different name, so take note of that.
  • Access points: Change the access point names provided here with the correct ones. Mywifi1 and Mywifi2 are the Wi-Fi networks your server is configured to connect to by default.
  • Password: Update the password for each Wi-Fi network.

enter image description here

Save the changes you've made and close the configuration file.

Step 2: Apply your changes using the following command:

sudo netplan apply

Alternatively, you can reboot your system and the changes will be automatically applied once the system boots.
How to Connect to a Wi-Fi Network on Ubuntu Server

Talaat Etman
  • 1,340