USB Ethernet Gadget Setup¶
This guide explains how to set up a USB Ethernet Gadget (g_ether) to connect a Raspberry Pi via USB and enable SSH access from a PC.
1. Raspberry Pi Setup¶
1.1 Enable OTG Function¶
Edit /boot/firmware/config.txt to enable OTG function.
Ctrl + X → Y → Enter).
1.2 Load Kernel Modules¶
Edit /boot/firmware/cmdline.txt to load dwc2 and g_ether.
rootwait:
Ctrl + X → Y → Enter).
1.3 Network Configuration¶
Set a static IP for the usb0 interface on the Raspberry Pi (optional).
1.4 Reboot¶
Reboot the Raspberry Pi to apply the changes.
2. PC Setup¶
2.1 Verify Network Interface After USB Connection¶
Connect the Raspberry Pi to the PC via USB and check the interfaces.
usb0 appears in the list.
2.2 Set IP on PC (Linux)¶
For Windows: Open ncpa.cpl, locate the usb0 adapter, and manually assign 192.168.7.1/24.
3. SSH Connection¶
Connect to the Raspberry Pi via SSH from the PC.
✅ Summary¶
- Enabled
g_etherto establish a virtual network over USB. - Configured
usb0on the PC with a static IP to enable SSH access. - No serial connection needed! Just a USB cable for SSH! 🎉