Raspbian Stretch OS Install with Wifi & SSH

This post will review the process for a headless  install of the Raspbian Stretch OS with SSH enabled and the Wifi connection information pre-configured. This is extremely useful when a Raspberry Pi (models: 3 B+, 3 B, 2 B, 1 B+, 1 A+, & Zero W) will not be connected to a monitor. 

Downloading and Extracting Raspbian Stretch OS

Download Raspbian Stretch OS (URL https://www.raspberrypi.org/downloads/)

Navigate to the dowloaded file and extract

raspbian latest.png
raspbian latest2.png

Flashing the Raspbian Stretch OS

To flash the extracted Raspbian Stretch OS to a micro SD card (8 GB or larger size suggested):

  1. Download & Install Etcher (https://etcher.io/)
  2. Plug the micro SD card into the computer
  3. Launch Etcher and select the Raspbian Stretch img file extracted in the previous step
  4. If needed, change the device to the micro SD card
  5. Flash the img file to the SD card
etcher.png

Enabling SSH

Open a text editor (Notepad)

Launch Notepad.png

Save the untitled notepad document to the micro SD card

  1. With the untitled notepad document open, select File>Save As...
  2. Navigate to the recently flashed SD card
  3. Set the Save as type to All Files (*.*)
  4. Set the File name to ssh
  5. Save

*Note* the notepad document should not contain any text. Saving the file to the SD card is letting the operating system know to enable SSH connections.

save ssh.png

Configuring the WiFi Connection

Configure the WiFi connection by:

  1. Opening another notepad document
  2. Copying and pasting the text identified below into the notepad document
    • Update the ssid value to your WiFi network name
    • Update the psk value to your WiFi password
  3. Select Save As... in the notepad document
  4. Navigate to the recently flashed SD card
  5. Set the Save as type to All Files (*.*)
  6. Set the File name to wpa_supplicant.conf
  7. Save

The wpa_supplicant document will need to contian the below infomation. (Update ssid and psk values appropriately)

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

network={
    ssid="YourWifiSSID"
    scan_ssid=1
    psk="YourWifiPassword"
    key_mgmt=WPA-PSK
}

wifi wpa_supplicant.png

Remove the SD card from the computer, insert the SD card into the Raspberry Pi, and power on the Raspberry Pi.

Identifying the IP Address for an SSH Connection

To identify the IP address assigned to the Raspberry Pi

  1. Prior to turning on the Raspberry Pi, on a computer that is connected to the same WiFi network
    1. Launch a command prompt and type "arp -a"
    2. Note the IP addresses that are listed
arp -a 1.png

3. Power on the Raspberry Pi
4. In the command prompt, reenter "arp -a" again and note the new IP address

arp -a 2.png

Use the new IP address for an SSH connection into the Raspberry Pi.

Establishing an SSH Connection

Launch an SSH client. (A popular and free SSH client is Putty and can be downloaded here: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)

Enter the Raspberry Pi IP address into the Host Name field and click Open. (The Port value should be 22 for SSH connections)

SSH Connection.png

When prompted click "Yes" on the security alert. This prompt will only be displayed on first SSH connection to the Raspberry Pi established on the computer.

SSH Prompt.png

Enter the login credentials for the Raspberry Pi. The default login credentials for a newly installed Raspbian Stretch OS are:

  • Username: pi
  • Password: raspberry
raspberryPi SSH Login.png

An SSH connection into the Raspberry Pi has now been established.

raspberryPi SSH connection.png