This is probably blindingly obvious, but I was quite pleased with this solution…
We just switched broadband providers and I got home to find the provider changed, new wifi router installed and the old one unplugged. Problem was I have THREE headless Raspberry Pi computers in the house – that’s to say Pis with no keyboard or screen. One is our wifi print server attached to an old laser printer, another is the internet radio in the kitchen, and a third is an experimental audio player running Volumio. Of course none of them would connect to the network now, as they had the wrong wifi network name and password inside them, and I couldn’t SSH into them to update them… because they couldn’t join the new network. Catch 22.
One solution might have been to connect them by ethernet to the new router, but I didn’t want to move them or then have the hassle of working out their new IP addresses. So I plugged the old broadband router back in, but did not connect it to the phone line. I then waited for the 3 RaspberryPis to connect to it, then I connected a laptop to the old wifi network. This had no internet access now, but it did allow me to SSH into the 3 RaspberryPis using their old IP addresses to edit the wifi details with the
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
command. I typed VERY carefully, as I only had 1 chance to get this right. Luckily, all 3 worked and then I unplugged the old router and switched the laptop back to the new wifi network. Simples!
PS: @ryanteck points out that an even simpler solution is to rename the new wireless network SSID and password to match the old one. I’d have done this but for the fact that a family members had already attached their phones, laptops and tablets to the new network and I couldn’t face telling them they’d have to change them back again. But it’s clearly a more sensible solution.
Ryan’s tweet has given me an idea though – keep an old router handy for use as a portable not-so-hotspot so if you take your headless Pi elsewhere (holiday, Raspberry Jam etc) you could use it to SSH into the Pi to update the wifi details. Again, there’s probably a much simpler way of doing this…