angrychimp
3/22/2018 - 10:07 PM

Raspbian - Wi-fi & SSH on first boot

How to get wi-fi and SSH working via image adjustments prior to a first boot.

  1. Download the image
  2. Flash the image to your microSD using Etcher
  3. Unmount/remount the microSD as necessary
  4. For wi-fi, add a file to the root folder named wpa_supplicant.conf
    • Content can be generated using
      read -p "SSID: " ssid
      read -s -p "Passphrase: " passphrase
      psk=$(wpa_passphrase $ssid $passphrase)
      echo "country=US
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      $(echo "$psk" | grep -v '#psk')" > wpa_supplicant.conf
      
  5. For SSH, add an empty file to the root folder named ssh:
    • Simply run touch ssh
  6. Unmount the card, and boot the device.
  7. After it boots, you should be able to log in using the default username/password pi/raspberry
  8. Make sure to change the default password after logging in
  9. Run updates
    • sudo apt-get update -y
    • sudo apt-get upgrade -y