Raspberry Pi/Headless Configuration

Headless Raspberry Pi configuration is a method to configure your Raspberry Pi without a keyboard and monitor from your OS (Windows, MacOS or Linux). It will allow your Raspberry Pi to be remote accesible via ssh and automatically connect to your Wifi, once you have copied your Rasbian OS in your SD card follow these steps:

1) Enable ssh remote access: Create a empty file without extension /boot/ssh
2) Configure your Raspberry Pi to connect to your Wi-Fi network:
2.1) Create a file /boot/wpa_supplicant.conf
2.2) Edit your new created file, if you are using Windows use Notepad++ to save your file in UNIX/Linux compatible format[1] /boot/wpa_supplicant.conf and add your Wi-Fi network name and password. Examples of different wpa_supplicant.conf files :

Basic wpa_supplicant configuration file:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="put_here_your_WiFI_network_Name_or_SSID"
    psk="put_here_your_WiFI_password"
}

More advanced, adding country code and key_mgmt information:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
    ssid="put_here_your_WiFI_network_Name_or_SSID"
    psk="put_here_your_WiFI_password"
    key_mgmt=WPA-PSK
}

You should replace your country= value with a ISO-3166-1_two-letter_country_code from your country. Check: https://www.iso.org/obp/ui/#search/code/

This option is available since 2016 and allows the Raspberry Pi to be configured modifying directly the image to start ssh and configure Wi-Fi connection parameter, which allow a Headless configuration (configuration without external monitor and keyboard). See: https://raspberrypi.stackexchange.com/questions/10251/prepare-sd-card-for-wifi-on-headless-pi

Once you connect to your Raspberry Pi do not forget to change the default password using the passwd command.

Reference

edit
  1. https://support.nesi.org.nz/hc/en-gb/articles/218032857-Converting-from-Windows-style-to-UNIX-style-line-endings