This works to initialize a headless RaspberryPi connected by Wifi (no screen/keyboard never needed attached to RPi):
Get a Raspbian Stretch Lite from https://www.raspberrypi.org/downloads/raspbian/ and write it to the micro SD card with Win32diskimager or Etcher
Add an empty
sshfile in the boot partition
Boot on Linux (or boot a Linux VM on Windows), or use Linux File Systems for Windows in order to edit
auto lo iface lo inet loopback allow-hotplug wlan0 iface wlan0 inet dhcp wpa-ssid "MyRouter" wpa-psk "92dc84ee7e7032be9142828023912e77" allow-hotplug eth0 iface eth0 inet dhcp
This works, I've done it many times in the past years.
Problem: for a Windows user, step #3 is not very convenient. An alternative would be to initially connect via ethernet cable, SSH with putty, and edit
nano, but it's not very handy too, because it requires to connect the RPi to the router with a cable.
Question: which method would allow to initialize a headless Raspberry Pi, including the Wifi ssid/password setting, 100% from Windows?
I see a few options:
A) Would there be a way, on a fresh Stretch Lite install, only by modifying files in the
bootpartition (accessible from Windows), to configure Raspbian to use a file
intefacesin the boot partition instead of the usual
B) Would there be a way to put a script
#!/bin/bash sudo cp /boot/interfaces /etc/network/interfaces
that would be launched on the first boot of the RPi? Then we could put both the
intefacesfile (written in the boot partition - easy from Windows) and the
copyinterfaces.shfile in the boot partition, and during the first boot, the boot partition's
interfacesfile would be copied to
C) another idea?
Once again, the goal is: to be able to set up a headless RPi connected by wifi, without using a keyboard/screen/ethernet cable ever, 100% from Windows, so that we can SSH with putty and never have to boot Linux (some users don't have any Linux installation), and never have to use an ethernet cable.