Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Hello friends.

Thank you for DietPi.

I have DietPi running on a Raspberry Pi 3, updated and fully configured, working fine on my local wifi network.

But I need to move it to another place, in another city, where it will be used as a temporary headless server.

In this new place, let’s say, there is no monitor and keyboard available for the Pi. And I need to reconfigure the Pi wi-fi settings for the new place wifi network, with ssid and password that I’ll know only when I come there. But my Windows 10 laptop with a SDcard reader will be available.

Is it possible to change the DietPi wifi settings editing some file on the SDcard with the Windows laptop?

Thanks,
Marcio

Hi,

WiFi creds can be pre-entered in /boot/dietpi.txt, after SD write, before 1st boot:

However, this only takes effect on a fresh image installation of DietPi. Has no effect on existing installations.

recommended to use notepad++ on a windows machine to modify/tweak those files, otherwise it could cause the carriage returns to not work and thus bork the /boot file

There is a portable version so you don’t have to install it…
https://portableapps.com/apps/development/notepadpp_portable

Here is the solution I have found to be able to write to the linux partition of a sd card using a Windows laptop, and edit the interfaces file.

You will need VirtualBox, a laptop with a sd card reader, and a Linux distro installed on VirtualBox. I have used Xubuntu desktop because it’s simple to use and will automount the card partitions.

  1. Open VirtualBox, select the Linux VM, and click on Settings.

  2. Click on “USB” and, on the USB page, click on the icon with a plus symbol, to add a new USB filter.

  3. Select the sd card reader on the list that appears below the add filter icon. In my case it was “Generic Flash Card Reader/Writer (0100)”. Then, click on “Ok”. Now start the virtual machine.

  4. Login on the Linux virtual machine.

  5. Open File Manager.

  6. Now insert the sd card in the laptop sd card reader. After a while all the sd card partitions will automatically be mounted and made available inside the Linux virtual machine. Check on the File Manager the newly mounted partitions.

  7. Open a terminal and type:

sudo nano /media/USERNAME/rootfs/etc/network/interfaces

  1. Edit the the interfaces file for your new network settings. Remember to put the same values on “wireless-essid” and “wpa-ssid”, and on “wireless-key” and “wpa-psk”, if you are using wpa-psk. After editing, use “Ctrl-o”, “Enter”, “ctrl-x”, to save and exit nano.
  • Original interfaces file: EDIT: REMOVED OBSOLETE LINK
#/etc/network/interfaces
#Please use DietPi-Config to modify network settings.

# Local
auto lo
iface lo inet loopback

# Ethernet
#allow-hotplug eth0
iface eth0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
#dns-nameservers 8.8.8.8 8.8.4.4

# Wifi
#allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid FuzonWifi
wireless-key abcde12345
wireless-mode Managed
wireless-power off
wpa-ssid FuzonWifi
wpa-psk abcde12345
#dns-nameservers 8.8.8.8 8.8.4.4
  1. On File Manager, click on the eject icon besides “rootfs”. Remove the sd card from the reader.

  2. Put the sd card on the single-board computer and boot it.

  3. Use ssh to connect to your single-board computer.

  4. If, for some reason, you’ve decided to use DHCP instead of a static IP, you may use Angry IP Scanner on the laptop to try to find the IP issued to the single-board computer.

Thank you for the answers.

Marcio

Perhaps an easier way is to put the SD in an adapter and plug it into a Pi. Mount the card. Then connect to the device with WinSCP and edit.

John

John, may you please explain it better?

Thank you,
Marcio

[quote=“arqeco”]John, may you please explain it better?

Ideally you need two Pi devices, one running an OS OK. The second device is the one you are trying to setup.

Flash the SD card with DietPi.

Install WinSCP on your Windows machine.

Put the SD card in an SD-USB adapter and put it in the working Pi (on any other Linux box). Mount the SD card on that device.

Using WinSCP SSH into the device that has your SD card mounted and then navigate to the files you want to edit. The WinSCP editor does the job nicely.

Ah if running a SSH shell on the Pi and the Pi is up and operational, like Fourdee said…

The interface config file is /etc/network/interfaces as arqeco said
Edit that file with nano or vi of the new remote site SSID and passcode then save normally.

    #/etc/network/interfaces
    #Please use DietPi-Config to modify network settings.

    # Local
    auto lo
    iface lo inet loopback

    # Ethernet
    #allow-hotplug eth0
    iface eth0 inet dhcp
    address 192.168.0.100
    netmask 255.255.255.0
    gateway 192.168.0.1
    #dns-nameservers 8.8.8.8 8.8.4.4

    # Wifi
    #allow-hotplug wlan0
    iface wlan0 inet dhcp
    address 192.168.0.100
    netmask 255.255.255.0
    gateway 192.168.0.1
    wireless-essid FuzonWifi
    wireless-key abcde12345
    wireless-mode Managed
    wireless-power off
    wpa-ssid FuzonWifi
    wpa-psk abcde12345
    #dns-nameservers 8.8.8.8 8.8.4.4

Powerdown, and ship the RPi and card to remote location…fire it up and it should come up as long

btw why it stated dhcp while we want to set it as static?

    iface wlan0 inet dhcp
    address 192.168.0.100

correct make it static

Answer:

  • duplicate ip addresses

and

#/etc/network/interfaces
    #Please use DietPi-Config to modify network settings.