agustamir
Posts: 3
Joined: Sat Aug 06, 2016 7:03 pm

trouble with headless/ssh setup

Tue Mar 13, 2018 4:49 am

Hey guys,

I recently setup my pi zero (2017-11-29-raspbian-stretch.img and I think it's booting fine) and I don't have a mouse/keyboard to connect to it so I followed a bunch of instructions online to try and get going. Here is what I have done so far:
Set up interfaces file:

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

My wpa_supplicant file is:

Code: Select all

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

network={
  ssid="rpi_test"
  psk="test_132"
}
I also created a file named ssh in the `boot` folder. I have an edimax wifi dongle connected to the zero and thats blinking alright. I was hoping to see rpi_test show up as a network in the wifi networks available but haven't seen it yet. Not sure how to proceed from here. Any help would be great!

User avatar
topguy
Posts: 4406
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: trouble with headless/ssh setup

Tue Mar 13, 2018 10:39 am

You should only put the files in the "boot" partition. The small FAT32 partition that can be accessed from windows. That is where you should have the "ssh" and "wpa_supplicant.conf".

I think you should leave the "interfaces" file alone.

User avatar
HawaiianPi
Posts: 2318
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: trouble with headless/ssh setup

Tue Mar 13, 2018 11:26 am

agustamir wrote:
Tue Mar 13, 2018 4:49 am
Hey guys,

I recently setup my pi zero (2017-11-29-raspbian-stretch.img and I think it's booting fine) and I don't have a mouse/keyboard to connect to it so I followed a bunch of instructions online to try and get going. Here is what I have done so far:
Set up interfaces file:
You should not need to do anything to the network interfaces file.
My wpa_supplicant file is:

Code: Select all

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

network={
  ssid="rpi_test"
  psk="test_132"
}
That looks okay, provided it was created with a pure text editor.
I also created a file named ssh in the `boot` folder.
You don't put anything in the /boot folder. You put it in the small FAT32 partition, which is the first partition on the card (and is labelled "boot").
I have an edimax wifi dongle connected to the zero and thats blinking alright. I was hoping to see rpi_test show up as a network in the wifi networks available...
Wait, what? You put the SSID and encryption passphrase for your existing router in wpa_supplicant.conf to connect to an already available network, not to create a new network.

Assuming that last statement was some kind of misunderstanding, and you are actually trying to set your Pi0 up for headless boot with SSH access, this is how I do it.

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 & 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.
  1. Grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
  2. Grab the Etcher software from https://etcher.io/
  3. Install Etcher and use it 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 choose the Raspbian .zip you downloaded, pick your SD card and write.
    • If you have trouble, verify the SHA256 checksum of the download.
  4. Remove and reinsert the SD card so that your Windows or Mac PC can see the small FAT32 partition on the SD card (labelled "boot").
    • If you get a message telling you the card must be formatted, cancel it.
  5. On the small FAT32 partition, create a file with the name ssh (or ssh.txt). It can be empty, the contents don't matter.
  6. If you are connecting the Pi to your router with an Ethernet cable, you can eject the card and use it to boot your Pi now.
  7. To connect to a wireless network, create another file on the card called wpa_supplicant.conf, which has the following inside:

    Code: Select all

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=US
    
    network={
         ssid="Your network name/SSID"
         psk="Your WPA/WPA2 security key"
         key_mgmt=WPA-PSK
    }
    • Edit country=, ssid= and psk= with your information and save the file.
    • Use a pure text editor, not a word processor to edit the wpa_supplicant.conf file.
  8. Make sure that both files are in the main directory of the small FAT32 partition, not in any folder.
  9. 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 a bit longer), then you should be able to SSH into the Pi and configure it how you like.

If you have attempted this and failed, then unplugged the 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.

If you have a Zeroconf network service installed (Apple's iTunes, Bonjour or Quicktime install Zeroconf), you can SSH into pi@raspberrypi.local (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 my logging into your router and checking the list of connected clients, or using a network scanner app (like Fing for smartphones) to find your Pi on your network.
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?

agustamir
Posts: 3
Joined: Sat Aug 06, 2016 7:03 pm

Re: trouble with headless/ssh setup

Wed Mar 14, 2018 1:35 am

Thanks for the detailed explanation! Yes I did have a misunderstanding about the wifi name and I fixed that bit. I also added the conf file to the boot partition and the Pi connected to my network! Thanks again :)

Return to “Troubleshooting”

Who is online

Users browsing this forum: No registered users and 25 guests