Raspberry Pi Zero W- SSH over USB

If you’re attempting to setup the Zero without Wi-Fi, the best method I’ve found is to utilize Ethernet over USB. This permits SSH over USB. There is quite a few guides illustrating this, but they all assume the host (the computer which you’re connecting the Pi to) will bridge with it’s own internet connection. This gives the Pi access to the router so it will be assigned an IP / register it’s local domain name.

The following steps rehash every other tutorial, but assigns a static IP address to the Pi so you don’t have to worry about bridging.

Modify the config.txt file in the boot parition of the image by adding the following line to the bottom of the file:

dtoverlay=dwc2

Modify cmdline.txt by appending the following after rootwait. Make sure to only use a single space character between settings in the file.

modules-load=dwc2,g_ether

Create a file named ssh to enable sshd on boot.

touch ssh # done! :) 

In the rootfs partition of the image modify /etc/dhcpcd.conf to setup a static IP:

interface usb0

static ip_address=192.168.5.1/24
#static routers=192.168.4.1
#static domain_name_servers=192.168.4.1

Insert your new pre-configured image into your Pi Zero. Wait for a new Ethernet network interface to appear, and manually configure it have an IP address which is on the same subnet as your Pi.

You should now be able to access your device via SSH.

Leave a Reply

Your email address will not be published. Required fields are marked *