0

Recently, I received a RPI zero w for a potential side-project at work, mounted the latest raspbian image to it and set it up for ssh'ing via USB using this tutorial. I was unsuccessful in ssh'ing into it using my work laptop (2012, sierra, 15" screen) using the ssh pi@raspberrypi.local command, and finally gave up. I keep getting the error message ssh: Could not resolve hostname raspberrypi.local: nodename nor servname provided, or not known. When I got home, I attempted the same thing via my personal macbook (mid-2015, el capitan, 13") and I have no problem ssh'ing into the pi. Hopefully, I can just get it setup to connect automatically to the wireless network at work by adding it as a network in wpa_supplicants.conf, and then just ssh over the wireless network, but i fear that i'll need to initialize the connection using the sudo ifup wlan0 command while in range of the network for that to work, which will require first ssh'ing via USB.

Regardless, I'd like to be able to ssh into the pi for machines other than my personal macbook. I attempted to ssh into on 3 machines at work, all of which i believe are running sierra, and have had no luck thus far. My guess is that this is macOS version related, but I'm not sure given the small sample size.

Is there some setting or other configuration I need to enable ssh over usb for other macbooks?

All I've essentially done to the headless raspbian(Stretch, version 9) image is:

  • touch ssh in the boot directory
  • add dtoverlay=dwc2 to the bottom of config.txt
  • add modules-load=dwc2,g_ether after the rootwait setting in cmdline.txt
0

You need to install Bonjour Service on windows machines. Bonjour is running on macs by default as its used by iTunes ect

Soon as you install you should be able to connect

ssh raspberrypi.local
  • the 3 machines I tested ssh pi@raspberrypi.local are all macbook pros. i haven't been using any windows machines, per the question. but i will confirm that mDNSResponder is running on all 3 – heliotrope Oct 10 '17 at 2:18
  • Yeah sorry about, im not sure why I though you had trouble using a windows machine, I was temporary cross-eyed I think. – Dr.Rabbit Oct 10 '17 at 2:34
  • yea, no problem.. I can see where you'd get that idea when I said the OS might be the problem (I was referring to OS version). So...I just randomly tried the command again on my worktop, and after a handful of tries...it worked. Strange. – heliotrope Oct 10 '17 at 2:36
  • any updates available for itunes ect? – Dr.Rabbit Oct 10 '17 at 2:38
  • it says 'no updates available' in the app store – heliotrope Oct 10 '17 at 2:40
0

The "Could not resolve hostname ..." message indicates the issue is more basic (the issue isn't specifically related to ssh. Anything that needs to access the remote host would fail with a similar error.)

Test this via ping raspberrypi.local

I am not in an office where I can test this, but as I recall... mDNS is based on link-local addresses which means both hosts must be reside on the same subnet.

Most home networks are just a single subnet ... which may explain why it works at home. At an office, you Pi and Mac might not necessarily be on the same subnet (especially if the Mac is using a wired network connection instead of WiFi). If this is the case, you can likely work-around the issue by disconnecting the Mac from the wired connection and connecting it to the same WiFi being used by the Pi Zero W.

If you know the IP address assigned to the Pi, you can add it to the /etc/hosts. E.g. if your Pi has an IP address 10.1.2.3, then create an entry in /etc/hosts which reads 10.1.2.3 raspberrypi (omit the ".local" since that suffix is a domain name reserved for use only by mDNS). Then connect via ssh pi@raspberrypi.

You can check to see if mDNS is running on the Mac (it probably is) via ps -ef | grep mDNS and can use sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist to start it if it is not already running (but I expect it probably will already be running.)

My guess is that when you use the Pi & Mac at the office, the devices are not on the same subnet. I would likely start here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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