I followed the guide to enable SSH over USB: https://artivis.github.io/post/2020/pi-zero/
On Host Computer:
- Ubuntu 20.04.3 LTS, fresh install
- Ubuntu host has the USB Ethernet connection IPv4 set to "Shared to other computers"
On the Pi:
- Rasbian 11 (bullseye), fresh install
/boot/config.txt
hasdtoverlay=dwc2
/boot/cmdline.txt
ends withrootwait modules-load=dwc2,g_ether g_ether.host_addr=82:54:68:48:e4:87
/etc/dhcpcd.conf
has
interface usb0
static ip_address=10.42.0.42
static routers=10.42.0.1
First, I reboot my Ubuntu host, plug in the Pi. Everything works great:
- I can ssh in like this
ssh pi@10.42.0.42
- Ubuntu host has:
$ ifconfig usb0
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255
inet6 fe80::51a6:b324:a028:10d2 prefixlen 64 scopeid 0x20<link>
ether ee:9b:bb:8a:fa:dd txqueuelen 1000 (Ethernet)
RX packets 320 bytes 45573 (45.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 407 bytes 38339 (38.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.42.0.0 0.0.0.0 255.255.255.0 U 101 0 0 usb0
$ sudo arp -n
Address HWtype HWaddress Flags Mask Iface
10.42.0.42 ether d6:bc:a0:7d:1e:e1 C usb0
The Pi has:
$ ifconfig usb0
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.42.0.42 netmask 255.255.255.0 broadcast 10.42.0.255
inet6 fe80::acff:803:1fa3:f65 prefixlen 64 scopeid 0x20<link>
ether d6:bc:a0:7d:1e:e1 txqueuelen 1000 (Ethernet)
RX packets 395 bytes 31955 (31.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 310 bytes 48465 (47.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.42.0.1 0.0.0.0 UG 202 0 0 usb0
10.42.0.0 0.0.0.0 255.255.255.0 U 202 0 0 usb0
$ sudo arp -n
Address HWtype HWaddress Flags Mask Iface
10.42.0.1 ether ee:9b:bb:8a:fa:dd C usb0
Yet after I do sudo reboot
on the Pi, and wait for 5 minutes, from the Ubuntu host I cannot SSH into the Pi.
The USB Ethernet connection IPv4 is stuck on "Connecting...". Then I set it to "Shared to other computers" and turn-off / turn-on the network connection. It’s says “Connected”.
And on the Ubuntu host I get:
$ ifconfig
enx82546848e487: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255
inet6 fe80::b6b3:cbe4:b286:815a prefixlen 64 scopeid 0x20<link>
ether 82:54:68:48:e4:87 txqueuelen 1000 (Ethernet)
RX packets 78 bytes 4168 (4.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3 bytes 788 (788.0 B)
TX errors 120 dropped 0 overruns 0 carrier 0 collisions 0
When I ssh over wifi, I can see that Pi's arp table cannot resolve to the host's Mac address.
$ sudo arp -n
Address HWtype HWaddress Flags Mask Iface
10.42.0.1 (incomplete) usb0
How can I make SSH over USB work even after Pi is rebooted?
It works on Debian 11.
(Both work: reboot and yanking out the USB cord)
Don’t know what causes it to break on Ubuntu