This will be a long read, but I hope it will answer all your questions.
This is the procedure I use for setting up headless boot with SSH and wireless network. It works with Raspbian Jessie or Stretch, Desktop or Lite, and with the built-in WiFi on the Pi3B(+) & Pi Zero W, or a Raspbian compatible USB WiFi dongle on other models. Everything is done before you boot, and can be done on a Windows or Mac computer which only has access to the small FAT32 "boot" partition of a Raspbian imaged SD card.
- Grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
- Grab the Etcher software from https://etcher.io/
- Use Etcher to write the Raspbian image to your SD card.
- You don't need to extract the image or format the card prior to writing.
- Just run Etcher, choose the Raspbian .zip you downloaded, pick your SD card and write.
- If you have trouble, verify the SHA256 checksum of the download.
- Writing an image to your card will erase everything previously on it!
- Remove and reinsert the SD card so that your Windows or Mac PC can see the small FAT32 partition on the card (labelled "boot").
- If you get a message telling you the card must be formatted, cancel it.
- On that small FAT32 partition, create a file with the name ssh (or ssh.txt). It can be empty, the contents don't matter.
- To connect to a wireless network, create another file on the card called wpa_supplicant.conf, which has the following inside:
Code: Select all
ssid="Your network name/SSID"
psk="Your WPA/WPA2 security key"
- Edit country=, ssid= and psk= with your information and save the file.
- Use the 2 letter country abbreviation in CAPS (without this you will have no WiFi).
- Use a pure text editor, not a word processor, to edit the wpa_supplicant.conf file.
- Make sure that both files are in the main directory of the small FAT32 "boot" partition, not in any folder.
- Safely eject the card from your PC and use it to boot the Pi.
If Raspbian finds an ssh file it will enable SSH and delete the file. If it finds a wpa_supplicant.conf file, it will move it to its correct location and connect to your wireless network. Give your Pi some time to boot and connect to your network (the first boot always takes longer), then you should be able to SSH into the Pi and configure it how you like.
If you have a Zeroconf network service installed, you can SSH into email@example.com (provided you don't have any other Pi computers on your network with the same default hostname). Otherwise you must SSH into your Pi's IP address, which you can find by logging into your router and checking the list of connected clients, or using a network scanner app (like Fing for smartphones). The latest versions of Windows 10 are supposed to support Zeroconf, and you can install it to older version with Apple's iTunes or Bonjour Print service.
To login using SSH from Windows, you can use an app called PuTTY, which looks like this (click picture for download link).
In the Host Name (or IP address) field, enter either,
Code: Select all
make sure SSH is selected (it should be by default) and click on Open.
If you have done everything correctly, a terminal window will open and you should see a password request. Although, if it's the first time you've connected to your Pi, you may have to answer "yes" to a security question, and then you'll get the password prompt. After login you'll get a warning about having SSH enabled with the default password, so type passwd[Enter] and enter a new password (twice). And now you can do whatever you need to configure your little Raspberry Pi computer.
Will bring up the Raspbian configuration utility. If you have more than one Raspberry Pi computer on your network it's a good idea to change the hostnames to something unique so that they can easily be identified.
If you have attempted this and failed, then unplugged power to turn off your Pi, you should start over with a freshly imaged card. Improperly powering down the Pi can cause SSH key generation to fail, which will prevent SSH logins (even if everything else is correct).
Alternatives to PuTTY:
If your main PC has the Windows 10 OS, there are 2 alternatives to PuTTY. The Windows 10 Fall Creators Update (2017) added the ability to install the Windows Subsystem for Linux, which is a Linux Bash shell for Windows (there are a few different versions of Linux in the Microsoft Store). And the recent Windows 10 Spring Update (2018) added OpenSSH directly to the Windows command and powershell utilities.
Raspberry Pi Zero:
The original model Raspberry Pi Zero and the newer version 1.3 with the camera connector do not have any build in networking capability. No Ethernet, no WiFi, and only a single micro USB OTG data port (the outer port is power only). So how would you connect a Pi Zero (non-W) to the Internet? You could use either a USB to Ethernet adapter, or as I prefer, a USB WiFi dongle. If you use a Raspbian compatible dongle, the procedure above works perfectly.
On my Pi Zero v1.3 I use a pcDuino USB WiFi Dongle with a tiny OTG adapter which fits inside of the USB plug of the dongle.
The components above (USB WiFi Donlge, OTG adapter, Pi Zero). Assembled below.
Just make sure you use a Raspbian compatible WiFi or Ethernet dongle that will not require any additional drivers.
Once you have SSH access you can use SCP to transfer files back and forth, or enable the VLC server included with the Desktop versions of Raspbian to access the Desktop remotely from your main PC using the free RealVNC Viewer software.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?