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
ssh
file in the boot partitionBoot on Linux (or boot a Linux VM on Windows), or use Linux File Systems for Windows in order to edit
/etc/network/intefaces
and add: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 /etc/network/intefaces
with 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
boot
partition (accessible from Windows), to configure Raspbian to use a fileintefaces
in the boot partition instead of the usual/etc/network/interfaces
?B) Would there be a way to put a script
copyinterfaces.sh
in theboot
partition:#!/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
intefaces
file (written in the boot partition - easy from Windows) and thecopyinterfaces.sh
file in the boot partition, and during the first boot, the boot partition'sinterfaces
file would be copied to/etc/network/interfaces
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.