Lasklo
Posts: 3
Joined: Sat Feb 09, 2019 11:33 pm

Cannot SSH Into my Raspberry PI Zero W

Sat Feb 09, 2019 11:52 pm

Hello! I am new to Raspberry PI's and need a bit of help! I have a Raspberry PI Zero W that my Dad got me from Micro Center and I'm trying to set it up to be headless with my Arch Linux Laptop. I have installed Raspbian Lite to an 8GB Micro SD Card, added the files "wpa_supplicant.conf" and "ssh" to the boot partition of the SD Card, put the sd card into the rPI. I plugged it in and waited for a few minutes for it to boot up, an LED light started flashing, then it stayed on. I assume this means that it is ready to go, but when I try to do

Code: Select all

ssh pi@raspberrypi
I get this error:

Code: Select all

ssh: Could not resolve hostname raspberrypi: No address associated with hostname
If anybody could help me with this, that would be greatly appreciated!

Ernst
Posts: 1140
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Cannot SSH Into my Raspberry PI Zero W

Sun Feb 10, 2019 7:15 am

Lasklo wrote:
Sat Feb 09, 2019 11:52 pm
Hello! I am new to Raspberry PI's and need a bit of help! I have a Raspberry PI Zero W that my Dad got me from Micro Center and I'm trying to set it up to be headless with my Arch Linux Laptop. I have installed Raspbian Lite to an 8GB Micro SD Card, added the files "wpa_supplicant.conf" and "ssh" to the boot partition of the SD Card, put the sd card into the rPI. I plugged it in and waited for a few minutes for it to boot up, an LED light started flashing, then it stayed on. I assume this means that it is ready to go, but when I try to do

Code: Select all

ssh pi@raspberrypi
I get this error:

Code: Select all

ssh: Could not resolve hostname raspberrypi: No address associated with hostname
If anybody could help me with this, that would be greatly appreciated!
There can be many reasons why that happens.
What I would suggest that you first ensure that setup of the access point does not have "wireless client isolation" enabled. Next you should check the contents of wpa_supplicant.conf to make sure that it is correct. Your file should look similar to:

Code: Select all

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

network={
    ssid="PiZone"
    psk="12345678"
    key_mgmt=WPA-PSK
}
The line "country=" must be included with a correct country code otherwise wifi will be disabled.
And at last, if you still have problems, I suggest you find a monitor and a keyboard to connect to the raspberry.

One more piece of advice, there is a small problem with raspbian that you must keep in mind, in particular if you do not have a monitor connected. On the first boot the root partition on the card is extended, on the next boot the ssh host keys are generated, if you remove the power too early the ssh host keys may be corrupt or not generated. For this reason you should not remove power too quickly, wait for the activity light calm down before pulling the plug.
Normally you should always do a proper shutdown and wait for the activity light to blink 10 times but that is difficult without ssh or keyboard to enter the command.

Edit: I may have made the wrong assumption that your router may be able to resolve "raspberrypi" to an IP-address.
Depending on a lot of things (ahavi/mDNS/bonjour) the name "raspberrypi.local" might be more successful.
The road to insanity is paved with static ip addresses

Lasklo
Posts: 3
Joined: Sat Feb 09, 2019 11:33 pm

Re: Cannot SSH Into my Raspberry PI Zero W

Sun Feb 10, 2019 2:41 pm

Ernst wrote: There can be many reasons why that happens.
What I would suggest that you first ensure that setup of the access point does not have "wireless client isolation" enabled. Next you should check the contents of wpa_supplicant.conf to make sure that it is correct. Your file should look similar to:

Code: Select all

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

network={
    ssid="PiZone"
    psk="12345678"
    key_mgmt=WPA-PSK
}
The line "country=" must be included with a correct country code otherwise wifi will be disabled.
And at last, if you still have problems, I suggest you find a monitor and a keyboard to connect to the raspberry.

One more piece of advice, there is a small problem with raspbian that you must keep in mind, in particular if you do not have a monitor connected. On the first boot the root partition on the card is extended, on the next boot the ssh host keys are generated, if you remove the power too early the ssh host keys may be corrupt or not generated. For this reason you should not remove power too quickly, wait for the activity light calm down before pulling the plug.
Normally you should always do a proper shutdown and wait for the activity light to blink 10 times but that is difficult without ssh or keyboard to enter the command.

Edit: I may have made the wrong assumption that your router may be able to resolve "raspberrypi" to an IP-address.
Depending on a lot of things (ahavi/mDNS/bonjour) the name "raspberrypi.local" might be more successful.
I have tried to ssh to raspberrypi.local, but to no avail. I do not have a mini HDMI to HDMI adapter, so I can not use a monitor with it. I could try to find my old OTG Cable to use my keyboard with, but I don't know if that would work without a monitor attached.

jbudd
Posts: 834
Joined: Mon Dec 16, 2013 10:23 am

Re: Cannot SSH Into my Raspberry PI Zero W

Mon Feb 11, 2019 2:09 am

Have a look at the SD card in your other computer. The wpa_supplicant.conf and ssh files should have disappeared from the boot partition.

Can you tell if your Pi is getting an IP address? I use IPScan24 on WIndows, fing on Android, Angry IP Scanner on Linux or just look in the router admin web pages.

If so, what happens if you try ssh pi@192.168.1.nnn (using the Pi's IP of course)?

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

Re: Cannot SSH Into my Raspberry PI Zero W

Mon Feb 11, 2019 6:18 pm

Do you have the Avahi/mDNS service running on your Arch Linux PC (avahi-daemon.service)?

https://wiki.archlinux.org/index.php/avahi

You could check your router's connected client list or use a network scanner app (like Fing for smartphones) to find the Pi0W's IP. Most routers also allow reserving an IP for a device in the DHCP settings (after which your Pi0W will always have the same IP, regardless of OS).
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?

Ernst
Posts: 1140
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Cannot SSH Into my Raspberry PI Zero W

Mon Feb 11, 2019 6:50 pm

You could run this bash command to find all devices on your network, in this example 192.168.0.0 is used:

Code: Select all

 
 /bin/bash -c 'for a in {1..254}; do ping -q -c 1 -W 1 192.168.0.$a >> /dev/null && echo $a; done'
The road to insanity is paved with static ip addresses

Lasklo
Posts: 3
Joined: Sat Feb 09, 2019 11:33 pm

Re: Cannot SSH Into my Raspberry PI Zero W

Mon Feb 11, 2019 10:18 pm

I'm sorry to say that I've tried all of your solutions, but to no avail. My dad and I checked the network to find that the rPI had not even connected to the network at any point. He also bought himself one and is going to be getting some Mini HDMI to HDMI Adapters for them. Thanks for your help!

chwe
Posts: 112
Joined: Tue Jul 31, 2018 1:35 pm

Re: Cannot SSH Into my Raspberry PI Zero W

Mon Feb 11, 2019 11:50 pm

Ernst wrote:
Mon Feb 11, 2019 6:50 pm
You could run this bash command to find all devices on your network, in this example 192.168.0.0 is used:

Code: Select all

 
 /bin/bash -c 'for a in {1..254}; do ping -q -c 1 -W 1 192.168.0.$a >> /dev/null && echo $a; done'
or as everyone else using nmap for such a job..

Code: Select all

nmap -sP 192.168.0.0/24
@Lasklo
an USB-UART adapter is always worth when dealing with headless systems.. e.g. Adafruit wrote a nice tutorial how to use it:
https://learn.adafruit.com/raspberry-pi ... ve-it-life

saves yourself a display.. especially on the pi zero where you would have to buy some sort of a USB-hub as well to connect a keyboard.

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

Re: Cannot SSH Into my Raspberry PI Zero W

Tue Feb 12, 2019 6:47 am

Lasklo wrote:
Mon Feb 11, 2019 10:18 pm
I'm sorry to say that I've tried all of your solutions, but to no avail. My dad and I checked the network to find that the rPI had not even connected to the network at any point.
That indicates a problem with the wpa_suppplicant.conf file. What did you use to edit or create that file? Also note that the Pi0W can only connect to 2.4GHz WiFi, if you were trying to connect to a 5GHz network it won't work.

The Pi0 series computers can be booted into USB Gadget mode, which allows you to SSH in over USB

You could try the Raspbian Lite image I have pre-configured for USB Gadget mode.
Click to download, 2018-11-13-raspbian-stretch-lite-Pi0USB.zip
SHA-256: 32ca25d28122cea2fd40d3f8d8c0e0ac2efd88fb5f569d0976828f42a604c2ed

It's the default Raspbian Stretch Lite image with Pi0(W) USB Ethernet Gadget mode pre-configured (config/cmdline .txt files modified and "ssh" file added with no other changes). Just write it you your SD card with Etcher and it's ready to go.
  • Put the card in your Pi0 or Pi0W
  • Connect a normal micro USB data cable to the USB data port of the Pi0 (the one closest to HDMI)
  • Do not connect anything to the power port (the one closest to the outer edge)
  • Connect the other end of the micro USB data cable to your main PC USB and the Pi0 should start to boot
  • Note that the first boot can take awhile, so give it a couple of minutes before you try to SSH in
It should boot up in USB Ethernet Gadget mode (system should have a new USB Ethernet/RNDIS Gadget network adapter), and you should be able to SSH into pi@rapsberrypi.local (make sure avahi-daemon.service is running).

This image was tested and confirmed working on my Windows 10 notebook with my Pi0W and a Pi0v1.3 with a USB WiFi dongle.
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?

Return to “Troubleshooting”