Score:1

Change WiFi config on headless Ubuntu server Pi zero 2 via SD card?

vn flag

I have a Raspberry pi zero 2 running ubuntu server with a WiFi connection.

I want to take the pi somewhere else and hook onto the WiFi in a new location. I will not know the SSID or the password until I am there. I will have my laptop with me but with no screen, keyboard mouse or ethernet connection for the Pi. Tethering through the laptop is not an option either.

Can I alter files on the SD card to update to the new SSID and password so that the Pi will automatically connect?

If so, which files?

Q-engineering avatar
ro flag
Please, take a look at this answer. [wifi setup](https://raspberrypi.stackexchange.com/questions/98598/how-to-setup-the-raspberry-pi-3-onboard-wifi-for-ubuntu-server-18-04-with-netpla)
Score:0
im flag

Answering to a one year old question but others may have the same question.

  1. before you go, while connected at home:
  • sudo cloud-init clean --logs
  1. before you go, mount the card in your desktop
  • edit /boot/network-config
ethernets:
    eth0:
      optional: true
      dhcp4: true
wifis:  
    wlan0:  
      dhcp4: true  
      optional: true   

or for a new WiFi (I like to use my iPhone hotspot - that way I know the SSID and the password)

ethernets:
  eth0:
    optional: true
    dhcp4: true
wifis:  
  wlan0:  
    dhcp4: true  
    optional: true   
    access-points:  
      "your_SSID":  
        password: "your_netpswd"
  1. Before you go, reboot the system twice
  • first time copies the new network-config to /etc/netplan/50-cloud-init.yaml
  • second time actually uses the /etc/netplan/50-cloud-init.yaml
  • if using your iPhone Hotspot, and you can log into the system with ether connection:
    • have the hotspot active when you boot
    • log in from ethernet, run iwconfig to see what the IP address is (it will be the same next time)
  1. When you get there
  • The Wifi you configured will work (e.g. iPhone hotspot)
  • or if you need to set the SSID/password,
    • edit /boot/network-config
    • yank power when green light is off to reboot two- three times
Score:-1
vn flag

The network configuration files are in /etc/netplan. Change them as you wish :)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.