SSH Over USB On A Raspberry Pi

The edge of a laptop is shown with a USB cable plugged into it. the other end of the cable is plugged into a Raspberry Pi Zero.

Setting up access to a headless Raspberry Pi is one of those tasks that should take a few minutes, but for some reason always seems to take much longer. The most common method is to configure Wi-Fi access and an SSH service on the Pi before starting it, which can go wrong in many different ways. This author, for example, recently spent a few hours failing to set up a headless Pi on a network secured with Protected EAP, and was eventually driven to using SSH over Bluetooth. This could thankfully soon be a thing of the past, as [Paul Oberosler] developed a package for SSH over USB, which is included in the latest versions of Raspberry Pi OS.

The idea behind rpi-usb-gadget is that a Raspberry Pi in gadget mode can be plugged into a host machine, which recognizes it as a network adapter. The Pi itself is presented as a host on that network, and the host machine can then SSH into it. Additionally, using Internet Connection Sharing (ICS), the Pi can use the host machine’s internet access. Gadget mode can be enabled and configured from the Raspberry Pi Imager. Setting up ICS is less plug-and-play, since an extra driver needs to be installed on Windows machines. Enabling gadget mode only lets the selected USB port work as a power input and USB network port, not as a host port for other peripherals.

An older way to get USB terminal access is using OTG mode, which we’ve seen used to simplify the configuration of a Pi as a simultaneous AP and client. If you want to set up headless access to Raspberry Pi desktop, we have a guide for that.

Thanks to [Gregg Levine] for the tip!

3 thoughts on “SSH Over USB On A Raspberry Pi

  1. I don’t want to diminish the possibilities of this feature. But the problem the author describes here hasn’t happened to me since I began using the Raspberry Pi Imager. It automatically adds wifi credentials, my personal login credentials as well as enables services like SSH by default.

    1. Recent versions of Raspberry Pi Imager are broken and don’t actually do what they’re supposed to do, leaving users wondering what they did wrong and why they can’t connect to their new Pi.

  2. And I am the lucky individual who submitted the tip. And sadly Andrew I agree with you on the Imager. I downgraded to the much older version I am now using because of similar issues. Oddly enough all connected with the zany issue I tipped the site about.

Leave a Reply to MiselCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.