7

I have a Raspberry Pi Zero and I am trying to setup headless mode for that pi. I followed all the steps here, but I have no luck getting a SSH connection to the Pi. The microcontroller is running Raspbian Jessie w/ PIXEL, while I am on Kali Linux rolling.

$ ssh [email protected]
ssh: Could not resolve hostname raspberrypi.local: Name or service not 
known

I want to tether a USB to the Pi Zero and connect in "headless" mode, and I did not setup network connectivity to the Pi, so if I use Nmap or anything like that, the Pi won't show up.

How should I fix this? I have looked everywhere. I have also setup the Pi Zero through an HDMI monitor and configured SSH so that it starts on startup, but no luck there. Is there anything I can do to fix this?

3
  • Do you have itunes installed on the machine you are connecting from? Using your router you can probably identify the IP address of your Pi and use that instead of raspberrypi.local. Feb 5, 2017 at 17:24
  • @SteveRobillard I'm on Linux. I want to tether a USB to the Pi Zero and connect in "headless" mode, and I did not setup network connectivity to the Pi, so if I use Nmap or anything like that, the Pi won't show up. I followed all the instructions from the guide I linked.
    – alcao758
    Feb 5, 2017 at 17:26
  • 1
    Do you have zeroconf/avahi installed on your Kali Linux? Otherwise the pseudo TLD .local. won't resolve.
    – TheDiveO
    Jun 23, 2017 at 14:30

6 Answers 6

3

Here is what I had to do to make that working :

  1. At the root of your micro sd card (when plugged on another computer) : create a file empty and save it as ssh with no extension:

    • touch ssh on unix or
    • notepad on Windows, save and choose . in file extension and "ssh" (with quotes) as name and save.
  2. Always at the root of the micro sd card, edit config.txt file and add a line at the end : dtoverlay=dwc2

  3. Then edit cmdline.txt and at the end of the line after rootwait, add a space and modules-load=dwc2,g_ether

  4. save all, eject your micro sd and put it in the pi zero. then plug it via usb port (not pwr but you can plug it also).

  5. If you still can't ssh [email protected] : on Windows, go to desktop, right click manage, then if you see that your rdnis ethernet gadget is not well installed, try to update driver, select yourself to install a network device and choose Microsoft and remote rdnis adapter.

Hope it will save time for somebody.

2

There can be different points why you cant connect your PI. The error message indicates that the domain can't be resolved. Try:

nslookup raspberrypi.local

does the response give the IP of the Raspberry? If not there is a DNS issue.
If you know the IP of your Raspberry try to connect using the IP:

ssh [email protected]

If it doesn't work or if you don't know the IP of your Raspberry, use HDMI and Keyboard. Login and check your IP:

ifconfig

while being on the Raspberry try to connect ssh from there:

ssh -vvv localhost

does it work? If no, post the error. If yes try to connect from there to your IP:

ssh -vvv 192.168.1.1
2

For some reason the zeroconf/avahi/bonjour/link-local/whatever-you-call-it isn't working. I have no idea why this happens or how to fix it, but you can work around it.

Method 1:

  • Connect your raspberry pi to your computer.
  • When it is recognized as a new network connection, open your network configuration.
  • Set the IPv4 method to 'shared to other computers'.
  • Reconnect to this network
  • Run ifconfig and check for a line like (the bold number must be 1):

    inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255

  • Run tail /var/log/syslog and look for a line like (the ip should be the same as in the previous line, except for the bold part):

    dnsmasq-dhcp[489]: DHCPACK(enp0s20f0u1) 10.42.0.114 12:34:56:78:9a:bc raspberrypi

  • Use this ip to connect: ssh [email protected]

  • If your computer has internet access, your raspberry pi should now have internet access as well.

Method 2

  • Insert the SD card into your computer and append the following lines to the etc/dhcpcd.conf on the storage partition:

    # Set a static ip for when connected to USB
    interface usb0
    static ip_address=169.254.64.64
    
  • Unmount the SD card and insert it into your raspberry pi zero.

  • Connect your raspberry pi to your computer.
  • When it is recognized as a new network connection, open your network configuration.
  • Set the IPv4 method to 'link-local'.
  • Reconnect to this network
  • You can now connect: ssh [email protected]
  • However, this won't provide your raspberry pi with internet access.
3
  • Method 2 assumes that you are using either a Pi Zero or Pi Zero W: only these two hardware versions support USB gadget mode, where you turn the Pi Zero/W into an USB device, which then appears as an Ethernet USB adapter at your PC. In addition, this requires you to reconfigure your Pi Zero/W to load the proper drivers for Ethernet gadget mode.
    – TheDiveO
    Jun 23, 2017 at 14:29
  • The question is about the Pi Zero, and it is pointed out that those configuration steps have been performed.
    – bcmpinc
    Jun 23, 2017 at 14:50
  • This is the only helpfull answer here. The pi is has dhcpd running, so it tries to get an address. Thanks.
    – alwe
    Nov 3, 2019 at 17:11
0

Usually people can't get SSH to work because they don't create the ssh file in the boot folder, as that guide asks you to do indeed. If you are sure you did that, and also tried to do this in non-headless way by manually enabling ssh on the device using monitor and keyboard, then I'd look for your problem on your network rather than on the raspberry.

I don't know about using "raspberrypi.local" to connect, try getting the IP of your device in your modem/router control panel or any other way.

1
  • Another way to detect all Raspis in your local net with their IP addresses (Adapt your local network) : nmap -sP 192.168.0.0/24 &>/dev/null; arp -n | grep "b8:27:eb"
    – framp
    Apr 15, 2017 at 17:45
0

I just set up SSH on my new model 3B.

  1. I used a mouse/keyboard/monitor to connect to the same wifi router as my laptop.
  2. I typed "ifconfig" into the terminal on the raspberry pi to show its IP address.
  3. I opened Terminal on my mac, typed ssh [email protected] (that was the pi's address) and logged in with password raspberry.
  4. You can use various tools to find the raspberry's IP address if you know what wifi it's connected to. I use an app called Net Analyzer on my iphone.
0

go to your settings you should see an ethernet connection with RNDIS/Ethernet Gadget. Then go to your setting and set the ipv4 to "share with other computers".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.