[Solved] SSH into a Pi over USB, totally stuck

What i’d hoped would take 1hr has almost been a day now. Has anyone had luck with SSHing into a Pi over USB? What steps did you take with which OS? The success stories i’ve read tend to be Windows/Mac, not many from Linux.

The Pi Zero has the latest Raspbian (Full) and is connected to my laptop running Debian (Bullseye) via it’s USB data port (not the power-only port).

All command outputs below are from my laptop:

lsusb # Output (Pi specific):

Bus 001 Device 034: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget

ip addr # Output (Pi specific):

4: enx8af6eead1756: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 8a:f6:ee:ad:17:56 brd ff:ff:ff:ff:ff:ff
inet6 fe80::88f6:eeff:fead:1756/64 scope link
valid_lft forever preferred_lft forever

ping fe80::88f6:eeff:fead:1756 # Output: (continuous)

64 bytes from fe80::88f6:eeff:fead:1756%enx8af6eead1756: icmp_seq=1 ttl=64 time=0.100 ms

ssh pi@fe80::88f6:eeff:fead:1756%enx8af6eead1756 # Output:

ssh: connect to host fe80::88f6:eeff:fead:1756%enx8af6eead1756 port 22: Connection refused

I’ve installed the OS to memory card adding the file “ssh” to the boot partition prior to first startup twice.
I’ve also gone in and manually turned on SSH using sudo raspi-config with no difference.

As for getting a non-IPv6 address…
Right after imaging the card, I went into the boot partition and:

  • Appended dtoverlay=dwc2 to config.txt
  • Added modules-load=dwc2,g_ether right after rootwait in cmdline.txt keeping 1 space on either side.

I did sudo apt install avahi* first on my laptop, tried connecting, then installed the packages on the Pi and tried again with no luck.

ssh pi@raspberrypi.local # Output:

ssh: Could not resolve hostname raspberrypi.local: Name or service not known

None of the following commands show anything:

  • avahi-browse -art
  • mdns-scan
  • avahi-resolve-host-name raspberrypi.local

sudo systemctl status avahi-daemon # Output: (Running)

● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-08-18 22:07:14 BST; 3h 57min ago
TriggeredBy: ● avahi-daemon.socket
Main PID: 24475 (avahi-daemon)
Status: “avahi-daemon 0.8 starting up.”
Tasks: 2 (limit: 23825)
Memory: 1.6M
CGroup: /system.slice/avahi-daemon.service
├─24475 avahi-daemon: running [host.local]
└─24476 avahi-daemon: chroot helper

sudo avahi-autoipd --debug enx8af6eead1756 # Output:

Found user ‘avahi-autoipd’ (UID 114) and group ‘avahi-autoipd’ (GID 126).
Successfully called chroot().
Successfully dropped root privileges.
State transition START-0 → START-0
Starting with address
State transition START-0 → WAITING_PROBE-0
sleeping 433ms
Ignoring irrelevant ARP packet.
sleeping 228ms
State transition WAITING_PROBE-0 → PROBING-0
sleeping 1630ms
Ignoring irrelevant ARP packet.
sleeping 819ms
State iteration PROBING-1
sleeping 1401ms
State transition PROBING-1 → WAITING_ANNOUNCE-0
sleeping 1999ms
Ignoring irrelevant ARP packet.
sleeping 1274ms
Ignoring irrelevant ARP packet.
sleeping 222ms
Callout BIND, address on interface enx8af6eead1756
sleeping 1999ms
client: Error: Attribute failed policy validation.
sleeping 1982ms
Script execution failed with return value 2
Ignoring irrelevant ARP packet.
sleeping 1182ms
State iteration ANNOUNCING-1
sleeping 1999ms
Ignoring irrelevant ARP packet.
sleeping 266ms
Successfully claimed IP address
State transition ANNOUNCING-1 → RUNNING-0
sleeping -1ms
Ignoring irrelevant ARP packet.
sleeping -1ms
Ignoring irrelevant ARP packet.
sleeping -1ms
Ignoring irrelevant ARP packet.
sleeping -1ms
Ignoring irrelevant ARP packet.
sleeping -1ms
^CGot SIGINT, quitting.
Callout STOP, address on interface enx8af6eead1756
Killing child.
Killing child.
Killing child.
Killing child.

Not entirely sure what the above command does but no joy pinging or SSHing into

The most valuable resources among the countless i’ve looked at:

Raspberry Pi WiFi Avahi mDNS config | Scientific Computing | SciVision
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way! · GitHub
Headless Pi Zero SSH access over USB - Raspberry Pi Stack Exchange
Connect to a Raspberry Pi Zero with a USB Cable and SSH

Would be highly grateful for any good ideas on where to look from here or what I might be doing wrong.

I didn’t know it was possible to use SSH over USB. I always thought SSH was network based, while USB serial connections are called UART.


Duckducking results into oblivion, the dawn a fading memory, a direction for want of where.
There I found the last I needed, silhouetted against a sunset sky, the day was won, the prize was ours.

This uses the “usbnet” driver Framework in Linux kernel v2.4 and above.

Ground up guide for Debian Bullseye and similar to SSH (network) over USB into a Pi Zero:

  1. Image the latest version of Raspbian onto a memory card, don’t insert it into the Pi yet.
  2. Open the boot partion

Append the following to the file config.txt


For the file cmdline.txt , insert the following after rootwait on the same line, make sure there’s a single space on either side:


Create an empty file in the same directory named ssh

  1. Open the rootfs partition

Append the following to the file /etc/dhcpcd.conf (swap 192.168.4.x for something else if it’s in use)

interface usb0
static ip_address=
static routers=
static domain_name_servers=

  1. Install the memory card into the Pi Zero
  2. Connect the PC to the Pi Zero’s USB data port (not it’s power port), this will power it on.
    Warning: Don’t use external power for the Pi in addition to your PC unless you have a USB cable specifically designed to prevent the two power sources from creating exciting electrical problems.
  3. Give the Pi ample time to complete it’s first boot, you can plug in HDMI to see how it’s going.
  4. On the PC run ip addr to identify the network device belonging to the Pi (for me it was enxca68fe0aa7d8 and changes each reboot). Use it to run the following:

sudo ip link set enxca68fe0aa7d8 down
sudo ip flush enxca68fe0aa7d8
sudo ip addr add dev enxca68fe0aa7d8
sudo ip link set enxca68fe0aa7d8 up

Test your connection to the pi:

ssh pi@ # Password is raspberry

Thank you to:

Raspberry Pi Console over USB: Configuring an Ethernet Gadget (Shallow Thoughts)
The GNU/Linux "usbnet" Driver


(Oops, I answered just a little too late)…

I know you well enough to know that your time is valuable. Your time is valuable enough that it’s probably not worth you getting stuck on this. I would suggest just getting a “cheap and cheery” USB GbE dongle, such as a TP-Link UE300. These are cheap on Amazon.

I have one of these personally, and it’s awesome. Totally Linux-compatible.

Sometimes the best thing is just to throw a little money at a problem, and buy some inexpensive tried-and-true hardware.

PS: the smallest, cheapest Pi I would buy, personally, is a Pi 3 Model A+. Not a Zero. For just a tiny bit more money and size, you get so much more: a full-sized USB port (not mini), the GPIO headers are there, the CPU is much faster, etc.

Pi Zeros seem to me like they are just a bit too excruciatingly cheap. Not cheap and cheery.

1 Like

I appreciate that esbeeb, I do get carried away in the chase. :stuck_out_tongue:

I wasn’t going to let this one go though… Linux has a real problem with USB monitor support and I need to solve it.

You’re right about the zero though, terrible for VNC lol, i’ll need to upgrade!

I can use it fine over network but I really want a single cable solution that doesn’t expose the Pi to the LAN. It can be locked down but it’s yet another attack surface and a bunch of complication if I want something closer to plug n’ play.

1 Like

With a couple of those above GbE dongles, you could just attach a crossover ethernet cable directly between the said dongles, then make a subnet just over that ethernet cable (there would be no gateway address, but you’d still have to specify IP address, and netmask).

I’ve done GbE-speed backups over FTP in this manner.

Is there a well-stocked, easily-available, inexpensive USB monitor that you’d recommend? Which conforms to some video standard over the wire, that we can trust will stick around, longer-term?

I have 2 dongles but one’s only 100mbps sadly, would be worth a speed test comparing it to straight usbnet.

That’s the problem, they all use a standard called DisplayLink which only works on very specific versions of Ubuntu, it’s a nightmare getting the drivers to work elsewhere. That goes for all USB monitors and USB to display adapters (excluding USB-C DisplayPort).

Getting that 3rd screen to work with a laptop is a real Linux blindspot. I’ve been doing it over LAN with xrandr hacks combined with tigervnc and SSH reverse port forwarding but I really need to tie it all together into a simple guide that preferably offers something close to that one-cable plug n’ play experience (in addition to a LAN based guide).

1 Like