As stupid as it sounds, here is the case:

tl;dr: ssh via wifi into Rpi works. ssh via usb works as well, but only when Rpi is connected to wifi. Why?

Imagine we have a Raspberry Pi Zero W working in headless mode running the latest Raspbian Stretch, up to date and all. Said Rpi has two modes of ssh manually established on it - USB (per instructions in Video_1) and Wifi.

Here's the funky bit - ssh over USB seems to be wifi dependant. Meaning, it is possible to establish an ssh connection via a usb cable and work normally (ssh pi@raspberrypi.local allows you to connect to the Rpi) when the pi is connected to wifi. Pull the plug on the router, and the USB connection is disabled - and you cannot work through it anymore.

What might be causing this? Is it possible to make sure that the two ssh connections - USB and Wifi - are independent? Could one even ssh into a Rpi via USB without the Rpi being connected any other network, such as on an airplane?

Current configuration:

Board: Raspberry Pi Zero W, headless

OS: Raspbian Stretch with desktop, version April 2018

Modifications made:

  1. Added a file named ssh to boot
  2. Added dtoverlay=dwc2 to the end of config.txt
  3. Added modules-load=dwc2,g_ether to cmdline.txt after rootwait argument
  4. Added static IP assignments of gateway and Pi to the end of dhcpcd.conf
  5. Added network information (ssid, password) to wpa_supplicant.conf

Video_1: https://www.youtube.com/watch?v=xj3MPmJhAPU&t=188s

Solved: The issue can be solved on Linux Ubuntu by changing the incoming Ethernet connection IPv4 parameters to Link-local-only

  • 1
    Do you connect your pc with an USB cable to an USB port on the raspi? How do you establish an ethernet connection for TCP to use for ssh through an USB cable? What are your modifications to cmdline.txt and config.txt to realize this? – Ingo May 3 '18 at 17:31
  • perhaps the raspberry pi needs an IP address to communicate over TCP/IP protocol used by SSH – Jaromanda X May 3 '18 at 22:52
  • Hi Ingo, to the end of config.txt I add dtoverlay=dwc2, and to cmdline.txt I add modules-load=dwc2,g_ether as an argument after rootwait. Also, Jaromanda, I append static IP's to dhcpcd.conf, which seems enough for Wifi ssh – Mike Meyers May 4 '18 at 6:26
  • 1
    I use ssh via a USB OTG connection with a Zero and no other networking, so it is not impossible ;) Probably you should include some more details about your configuration. – goldilocks May 4 '18 at 15:15
  • Edited, thanks for the heads up! Anything you think I missed? – Mike Meyers May 4 '18 at 15:41

Don't know for sure, but I'm guessing that it could be something to do with the WiFi being a USB device (as is the Ethernet I/O). My guess is turning off the WiFi is disconnecting or powering down the USB hub chip?

  • Could be, but it's a Raspberry pi Zero W - the wifi has it's own antenna and location on it, right? – Mike Meyers May 10 '18 at 15:48

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