Raspberry Pi Zero – Programming over USB! (Part 2)

Summary

An extremely simple new way to setup Raspberry Pi Zero as a USB virtual network gadget, allowing SSH, SFTP, VNC etc over a single USB cable. All without need of a keyboard, mouse, screen etc to setup!
To make it clear though, this can only work with the Raspberry Pi Zero.

Quick history lesson

So back over Christmas 2015, I had worked on getting the Raspberry Pi Zero OTG/Slave USB mode working and documented. My work was based off the excelent work done by awesome volunteers from the Raspberry Pi community here and here.
Back then, it required you have a screen, keyboard, mouse and internet connection to set everything up from a stock Raspbian image. This was a bit of a pain if all you had was your normal Windows/Mac/Linux computer with downloaded Raspbian, an SD card, Pi Zero and a USB cable.

Then, with the 2016-05-10 release of Raspbian, the required modules and kernel version were included on the stock Raspbian images, but they still required configuring. At least all this could be done with a screen and keyboard plugged into the Pi Zero (no internet required).

Now, after a heck of a lot of Linux Kernel documentation digging/hunting around, I have stumbled across what seems to be a very little known kernel cmdline parameter. This parameter allows us to do all the configuration on the /boot partition, which is formatted FAT32 and readable on Windows/Mac/Linux (vs normal root partition only being readable with Linux).

What does this mean?

You can now set up a virtual network connection between your Raspberry Pi Zero and normal PC using a single USB cable in a matter of seconds, without the need for any extra hardware!
No need for an HDMI screen, keyboard, mouse etc, all with stock Raspbian Jessie lite or full.
You can then SSH into the Raspberry Pi Zero, copy files with SFTP or use VNC (extra installation required).

How do I set it up?

Setup is super simple! Once you have flashed your Raspbian image, should take only a few minutes to set it up! See guide below.

This can only work with the Raspberry Pi Zero, given USB is directly connected to the processor, where as the larger Pis it goes via the LAN hub chip. A and A+ are missing the ID pin so can’t dynamically detect USB master or slave, so defaults to master.

I wonder if this will work with the other Pi units. It would be really handy when working with Micro-Controllers and cannot get to the board easily. It would make mass setup of a bunch of units easier.

I seem to be having a senior moment here, which, due to my age is appropriate.

My main computer runs Windows 10. I’ve got the PiZero plugged into one of the USB ports using a micro usb male to normal usb male plug. I put the micro end into the non-power port, the one closest to the HDMI plug.

The lights are on … but nobody seems to be home.

When I use putty (port 22) to connect to raspberrypi.local it doesn’t find anything.

Ted
I also spent quite some time on trying to set this up!
Problem 1 – just could not see the using boot directory, config,txt or cmdline.txt files in my Win 10 File Explorer; so I had to set up the keyboard/TV again so that I could access the Zero boot directory, and then alter the two files using the terminal and “sudo nano config.txt”. Save, reboot, and dismantle, then back to the USB plugin on my Win 10 laptop
Problem 2 – fiddling around with Device Manager to work out which update to give the “yellow triangled Ethernet device” but eventually, it came up as a working USB.
And then the Zero worked as a plug in USB over PuTTy.

So maybe not quite the ‘super simple’ setup young Andrew writes about !! But hey! got there!

I am not sure what is up here, but I have had no issues with Windows 10 and it appearing? The Raspbian SD card image includes a FAT32 partition and an ext3 partition. Windows will be unable to read the ext3 partition, but FAT32 is a standard partition format that Windows will happily accept, as the many other people trying this out have found without any issues.
Windows 10 also should include the USB Gadget ethernet device driver, given it is actually just emulating a standard USB ethernet device, nothing special about it.

Could perhaps there be something weird with your Windows 10 setup? Perhaps a machine connected to an enterprise network (and in turn locked down with Group Policy) or have something like an antivirus software that doesn’t like external devices?
I am certainly not able to reproduce any of the issues you have brought up and is first anyone has reported them?

Andrew – my apologies for being a bit snarky – you certainly do know what you are talking about [ and your extremely impressive “About Me” makes that point very convincingly]

I retraced my steps and have identified my problem.

1. Root cause – I had not enabled the “hidden/disabled” administrator account on Windows 10. [I was under the impression that Win10 accounts had administrator rights.]
2 Yesterday, when working through raspberrypi.org, I downloaded Jessie and the Win32DiskImager, but Win32DiskImager wouldn’t run because it needed elevated rights. I backed off from sorting that out, and headed for the NOOB download and the raspberrypi.org method for copying files to the SD – and amending the config.txt and cmdline.txt files on my Zero. That worked – but a bit tedious on setting up the TV/keyboard/mouse front.
3 This morning, I enabled the Win10 administrator account; ran the Win32DiskImager; and with the Jessie image on SD was able to quickly and simply amend the config.txt and cmdline.txt files.
4 Simples!!

Apologies again –
YOU WERE RIGHT – this IS a “super simple” way to set up access to the Zero [though older folk like me might need to be gently reminded to work as an administrator]

I had exactly the same problem. After plugging the USB cable between the Pi and the PC, in Device Manager, I get a Network adapter: USB Ethernet/RNDIS Gadget but with a yellow triangle. After I right clicked on the entry, then clicked “properties”->”advanced” I entered an IP address. This fixed the yellow triangle. Everything started working and I could log into the Pi zero.

And same here. Windows 10 I followed your instructions, edited config.txt and cmdline.txt, added ssh file onto sd, installed Bonjour on my Windows machine, connected through decent USB cable. Raspberry booted up I believe, green LED became solid but I have no connection on SSH using Putty to raspberrypi.local. There is no ethernet device in device manager but there is a serial device instead.

For those that want to have internet access on the pi after doing this and are using windows:
On the windows pc enable internet connection sharing (Control Panel > Network and sharing center > Adaptor settings > Properties > Sharing) .
Don’t use a static IP address on the pi as internet connection sharing is not compatible with static IPs! (took me a while to figure out)
With static IP disabled, To connect to the Pi use its host name. For windows to find devices by host name you will need to install bonjour or (samba?) or similar.

I cant seem to figure this out. I am getting a 169.254 address on my pi and virtual interface which tells me it cant reach a dhcp server(my router). I cant update my pi because it cant resolve the domain names to grab the files because it seems that dns isnt working. I have network sharing enabled. Am I doing something wrong?

I’m fairly certain that the windows pc acts as the dhcp server for the device that the internet connection is shared to. (PC = DHCP server for pi)

For me the pc uses the addresses:
192.168.137.1 on the (USB Ethernet/ RNDIS Gadget) 192.168.1.7 for the ethernet connection provided by my routers DHCP server.

The Pi Zero reports an address 192.168.137.*

where * changes each time it is booted. So far I have not found a way to stop the pi’s address changing while still maintaining connection.

I don’t understand the process well enough to know what the problem you’re having is caused by, but as a quick suggestion, make sure that internet connection sharing is enabled on the network adaptor that has your current internet connection on. Secondly try testing with any other networks disabled. (i.e. only enable the network with internet access and the Pi Zero connection.

169.254.x.x means that it can’t pick up an IP from the DHCP server which will be the local WIN 10 PC.

Ensure that the Raspberry PI is connected to the USB cable and is powered. Second, if you didn’t add a file call “ssh” with no extension in the root of the MicroSD then you probably will need to do this first anyway. As the chaps decided to turn off the SSH service as a security point.

On the Windows 10 PC.

Ensure that you allow it to share the network of the PC. Via Right-hand mouse click over the WiFi/Network ICON on the task bar – “Network and Sharing Center” Select “Change Adapter Settings” on the left of the page. Normally second line down. Select the current network that is connected to the internet. Either a WiFi or Ethernet. Select the connection. Select righthand mouse. Then, select “Properties”, then Select Tab “Sharing” on the righthand side of the panel. Then, select under the “Internet Connection Sharing” the Tick box ” Allow others users to connect through this computer’s Internet connection”. Under this line, there will be a drop down box “Select a Private Network Connection” Select this and select the Network which is normally Network 4. (May be different). Then, apply. This will make Windows 10 setup the rules. Now, check on the Putty session to see if you can ping http://www.google.com. If not you probably have got the wrong Network connection. Go back and choose another. You will get there in the end.

Hi, I did connect my host computer to my PiZero through SSH, and the internet is shared as you mention, no STATIC IP, but I still have problems to connect the PiZero to internet. I think, the problem is that the dynamic ip that my computer gives to the PiZero is not in the same ip address 192.168.1.*/24, instead, the PiZero ip adddress is 169.254.*.* . What I am missing?

Hey @rena2019, good catch with IPv6. I have the same problem and your idea with connection via IPv6 worked with my RPI Zero. Aside from not being able to connect with just pi@raspberry.local instead of IPv6, after connecting my RPI Zero, the network-manager in my Xubuntu 14.04 gets crazy every minute or so and its icon is spinning for a few seconds.

I also had the same problem with the USB-network only working over IPv6 on Ubuntu 14.04, but I figured out how to also get it working over IPv4, which ‘fixes’ raspberrypi.local 🙂

You need to go into the network-manager menu, Edit Connections… and edit the new Ethernet connection (for me it was “Wired connection 2”). Switch to the IPv4 tab, and change the Method to “Link-Local only”. Click Save and then Close.

The usb0 network interface will then get assigned a 169.254.x.y address, and “ssh pi@raspberrypi.local” will work just like it should.

I did boot Raspbian with power, USB keyboard and HDMI and was able to successfully do “ssh localhost”, so sshd is running.

The syntax seems to be correct as this change from usb0 to (non-existant) usb1 shows:
$ ssh -6 pi@fe80::d489:a2ff:fe22:3f9a%usb1
ssh: Could not resolve hostname fe80::d489:a2ff:fe22:3f9a%usb1: Name or service not known
$

What can be the reason the very last step of doing the actual “ssh” gets refused?

Has anyone figured out a way to do this with an Android phone? I assume you would need a phone capable of OTG ethernet. It would be so convenient for me to be able to plug my deployed zeros into my phone instead of my bulky laptop in the field.

Android phones are actually really easy. Just connect with OTG cable and micro USB cable, and in settings on your phone, go to More (at top near networking settings), then you should see something about tethering and hotspots, and in that menu you can activate USB Tethering. IP subnet should be the same on all phones, 192.168.42.0/24. Use the app Fing to search that subnet and you should find you RPi zeros up address, and you can use your favorite SSH client on your phone to connect to it

Rebuild the SD card twice, downloaded another image, twice, the keyboard has worked, is working with raspberry pi 2, and the pi/raspberry still doesn’t work on the Zero.
The Bonjour configured the firewall, it shows Google Chrome (mDNS-In) owns the 5353 inbound UDP port.
Tried ‘sharing’ the ‘Ethernet’ connection and lost connection to my local network…..
I ordered all the cables, USB powered hub and another large bottle of TUMS.

After following the instructions on my newishly reinstalled Windows 10 Home 64 bit the pi appeared in device manager and as an ethernet adaptor but was assigned a default address in the 169.xxx.xxx.xxx range.
To make it work I had to also do the following:
1. Install Bonjour print services from the link in the post (as documented – I had already done this before connecting the pi)
2. Go into Network & Sharing centre
3. Click on my active internet connection – in my case Wi-Fi – opens the connection Status dialog
4. Choose Properties – opens the connection properties dialog
5. Select the Sharing tab
6. Check the box “Allow other network users to connect…”
7. Select the connection corresponding to the USB Ethernet/RNDIS Gadget – in my case Ethernet 5
8. Hit OK.
After a short pause the connection address changed from the 169 range to 192.168.137.1 and I was able to point my ssh client at raspberrypi.local and connect.
It may be that your machine already had ICS configured – no matter – what a handy thing to be able to do!
Collateral benefit is that enabling ICS gives the Pi internet access from the start – I know this has already been covered in the comments but I found that ICS was essential in order for the Pi and the USB Ethernet device to get assigned addresses.
Here’s another challenge – can this be adapted so that several Pi Zeroes can be connected via USB (hub? hubs?) such that they are all networked together and sharing just one ethernet or wifi dongle? Would be a great basis for a Pi Zero cluster!

I am actually going to begin working on this and have begun my acquisition of pi zero’s. (Microcenter still only lets me buy one per visit so I go every day during my lunch hour) Thinking of using a raspberry pi 3 with 4 usb 4 port hubs and 16 pi zeros set up. Im only on day 3 of my acquisition though…

Okay so it turns out the ICS thing is handy but not essential – raspberrypi.local is resolving to an IPV6 address so it’s not using the ICS at all – except that the Pi can see the internet via network adaptor usb0 which has an IPV4 address too – assigned from ICS. I’m still fascinated by the idea of a Pi cluster just using a master Pi connected to a wifi dongle or ethernet adaptor and several slave PiZeroes connected to it…

Ok after following this tutorial, I am now operating my Pi completely headlessly and with internet access (Windows):
1. Follow the instructions in the tutorial
2. Once the Pi Zero appears as an ethernet device in device manager make sure the drivers are completely up to date (Right click and search online for drivers) luckily windows found them and pulled through for me.
3. Open up putty and SSH using default port 22 and the address rapberrypi.local
4. If all you want it terminal access stop here, if you want graphical access continue.
5. You may want to configure the Pi Zero to have a static IP address on your home network, therefore you will need to edit the network interfaces file, type in “sudo nano /etc/network/interfaces” on your putty terminal.
6. Comment out everything but the line “source-directory /etc/network/interfaces.d” and add all the information corresponding to your network setup as such:
(information can be obtained by using cmd on your windows computer and typing “ipconfig” recording all important addresses such as gateway, broadcast etc if you dont already know them)
*************************************
auto lo
iface lo inet loopback

7. Hop back over to your windows computer and go into “change adapter settings” in the networks and sharing center.
8. Click on properties on Pi Zero ethernet adapter, and then click on ipv4 properties, set the IP address acquisition to manual and enter the static IP address you want assigned to the Pi Zero, along with the broadcast address, leave the gateway blank.
9. Save these settings, and then highlight your Wi-Fi / Ethernet device and also your Pi Zero eth adapter and then click on “add to bridge” – this will bridge these two adapters and allow internet access to be shared.
10. Restart your Pi Zero with the changes you made in step 6.
11. Restart your computer also if necessary.
12. When your computer starts up head over to putty log in to your Pi and type ifconfig in the terminal, you should see the ip address you assigned appear as the IP address of the device.
13. Double check connections by pinging the IP address of the host device and then ping http://www.google.com , if this does not work try pinging 8.8.8.8 which is a google nameserver, if it can get a response your DNS configuration may be an issue. Please check your route table and ensure that it has added the route to your host computer and to the router.
14. If you can ping google you are in good shape, type in “sudo apt-get install xrdp” , then reboot
15. Windows should already have installed remote desktop connection, type in the IP address you have assigned to the Pi Zero and you should be able to set up a remote connections, complete with visual control over the single USB cable!
16. If you have any issues, post and I may be able to help.

Hello
I don’t use remote desktop. I use the PI’s (zero and ) X11. Nothing extra to install on the PIs. Putty has an X11 server, which I have used (actually the Cygwin’s server). From my Linux machines (including other PIs) I install Xephyr. From my Linux PC (or another PI with Xephyr) I have a script that does:
Xephyr -ac -screen 1728×972 -br -host-cursor -reset -terminate :3.0 &
sleep 5
xterm -display :3.0 &

Xephyr then displays a blank window, until xterm show up. In that xterm I run a script (use the appropriate IP for the zero) :

In a few seconds, the remote zero, or pi, or even any Linux (Ubuntu even has a version that you can run in the cloud) will send a full desktop to your X11 server. Absolutely nothing extra to install on the PI (after you get ethernet running). Since Linux on the PI & zero is multi-user, I’ve connected from one Windows machine (Cygwin), and someone else connected to the Pi from their Windows (Putty/X11server) at the same time. slowly..

Disconnect the pi and see if you can still ping 10.1.18.244 from anywhere. You may genuinely have two machines with the same IP, if .244 is within the range handed out by your DHCP server. Or if you earlier configured another pi with the same setup and forgot it was still plugged in somewhere?

I started from scratch but before adding ip information in the interfaces file I went to Network and Sharing Center / Change adapter settings and there I was able to ‘highlight’ Ethernet 2 (ZERO) and Local Area Connection then bridge them. The bridge operation gave Zero a DHCP address and I reserved that address in my router.
sudo apt-get update now works!

I wonder if anyone else has played with separating networks using this to demonstrate to learners in networking that what seems like homogeneous device ecosystem (A.K.A Internet of Things), can actually be many devices connected over different interfaces and protocols.

I’m working on something with wireless-lan, using rPi3 as a wireless access-point, that has rPi-zero’s connecting over wlan using built-in credentials from /etc/wpa_supplicant/wpa_supplicant.conf. Trying to switch to USB over gadget mode I feel kinda stumped…

I’m not even sure how practical it would be to have N rpi-zero’s, but just the fact it could be boxed up, easily and affordably presented to showcase such a wide array of connected concepts interests me.

Hi, I have used the information in the post and in comments to somewhat make pi zero work with my Ubuntu 16.04 desktop: I can ssh into the PI Zero, but I am really struggling to make the pi access the Internet through my PC. Is there a way to do that?

Once I had the pizero connected as a usb slave and was able to ssh to it/apt-get update etc. I added the network section to /etc/wpa_supplicant/wpa_supplicant.conf for my wireless lan so now I can run it either in usb slave mode when I want to change things or just plug in a usb wifi dongle and connect power to run headless. No other changes needed as it detects which mode to run in by what it’s connected to. Great!

I was doing lots of experimentation with this last night, and found that every time I reboot the Pi Zero, it generates a new random MAC address for each side of the USB-network connection. On Ubuntu this is especially annoying as it creates a new “Wired Connection N” for every unique MAC address it sees – I got up to “Wired Connction 10”! (And for each new Wired Connection that got created, I had to manually set it to LinkLocal as described earlier)
I did a bit of searching, and found some useful info at http://wiki.openmoko.org/wiki/USB_Networking about hardcoding the MAC addresses. In my case (after connecting to the PiZero over SSH) I added:
options g_ether host_addr=26:7f:62:5c:48:86 dev_addr=d6:fe:44:ad:8f:13

to the file /etc/modprobe.d/g_ether.conf and after rebooting again, both sides of the connection now have a static MAC address, which means Ubuntu doesn’t create new “Wired Connection”s, and I was able to then go and delete the all old / redundant “Wired Connection 6” etc. that it had created.
In the g-ether.conf file, host_addr determines the MAC-address on the PC-side of the connection, and dev_addr determines the MAC address on the PiZero-side of the connection.

One thing I noticed is the MAC address of the network connections (on both the device and host) are randomly generated at each boot. This is a bit annoying if you want to use a DHCP server to reserve a IP address for your gadget.

I got round this problem by adding the following after “rootwait modules-load=dwc2,g_ether ” in the “cmdline.txt” file:
g_ether.dev_addr=11:22:33:44:55:66

You can also specify other options for host_addr, iManufacturer and iProduct, but I haven’t had time to try these.

LOL, I noticed the same thing about the random MAC addresses too (and found it annoying for a different reason), and I also posted a note about how to fix it earlier today as well! (but my comment contains a couple of URLs, so it hasn’t been approved yet).
Great minds think alike, etc.

Your way of fixing it (by adding options to cmdline.txt) is slightly neater than my way of fixing it (by adding options to /etc/modprobe.d/g_ether.conf) though 🙂

Adding that after the modules-load=dwc2,g_ether did not work for me, did you enter this as a new option (space separating it from “dwc2,g_ether”) or as another option t modules-load (comma separating it from dwc2,g_ether)?

Does the rpi0 have two usable USBs? If so, you could build a cambridge ring from them, each one daisychained to the next. [I actually did that (many) years ago with the BBC Micro’s serial port, but that required more complex software – because there was only one serial port, data out went on the TX pin but replies had to go all the way round the ring to come in on the RX pin from the machine on the other side!]

Nope – the BCM2835 (SoC used on the Pi Zero) only has one USB interface, and this is directly exposed on both the Zero and A+ (and ComputeModule). The B+ / Pi2 / Pi3 all use a LAN9514 to provide an Ethernet interface and 4 downstream USB ports (i.e. using a built-in USB hub).

I’ve been trying this on a Macbook Air and I can’t seem to get the raspberrypi.local address to resolve. Are there any other troubleshooting steps you can suggest? It definitely boots and I have made the changes to the two files.

Yeah, I guess some USB -> microUSB cables will be power-only (i.e. only two wires connected) – they will still allow the Zero to receive power and boot up, but the PC won’t “see” it.
You need to use a “normal” USB -> microUSB cable (i.e. with all four wires connected – two for power and two for data) to allow the PC to see the Pi Zero as a USB device.

Excellent stuff – I’ve been developing using the a pi set up with the original instructions all year now 🙂
But … trying the New Simple Method on a Mac has turned into a World Of Pain – the Pi shows up as either an RNDIS device (g_ether) or CDC device (g_cdc) … but I don’t seem to be able to get the Mac to serve it up an IP number 🙁
Oh well, a bit of virtual box and such will let me sort it out.
Did anyone get this to work with a bit of Mac configuration ?

I was able to get it working fine using Mac OS internet sharing without any issue? By default though you shouldn’t need one as should work for dirrection connection (without internet) using raspberrypi.local (bonjour).

I’ll take another look – I looked at the avahi config on the “fresh” image, and it has nothing to enable avahi to advertise the ssh service – just remote disk management.
Perhaps everything work fine letting the Mac and the Pi do self assigned numbers (in the 169.254.0.0/16 network)?
I shall report back.

I haven’t looked at it in detail, but AIUI avahi (a.k.a. bonjour a.k.a zeroconf) is only used here for the name-resolution, i.e. mapping raspberrypi.local to the 169.254.x.y that actually got assigned to your PiZero. As Dody Suria Wijaya noted in another comment, if you change the hostname on your Pi to e.g. mypizero than Avahi maps mypizero.local to 169.254.x.y (and raspberrypi.local won’t exist).

Hi Andrew, I tried this all again with a fresh image … and by following the following steps, everything works – and there’s a note at the bottom about what I think was wrong.

1. Modify the /boot/cmdline.txt & /boot/config.txt per The New Simple Method
2. On the Mac, in “System Preferences”, ensure that the “RNDIS/Ethernet Gadget” interface, if it is there, is set to DHCP
3. Make sure that Internet sharing is NOT enabled. If it is and you have another Pi called “raspberrypi.local”, Bad Things Happen and you may never connect to your Pi over ethernet.
4. Plug the Zero into the Mac with your (known working) micro-usb cable … and wait …
5. After a while (about two or three good swigs of tea), use “ping raspberry.local” … and behold, the Zero should respond, and the IP number will be revealed. If not repeat this step. You will not need a new mug of tea.
6. Use ssh to log in with the IP number from #5.
7. Some while later, note that avahi/zeroconf/bonjour has got the rhythm and that using “ssh pi@raspberry.local” now works.
8. Change the hostname to something sensible (i.e. unique and memorable), and reboot
9. Once you can connect using the new hostname, have a go at enabling Internet Sharing for the “RNDIS/Ethernet Gadget”. Don’t change the DHCP setting on the RNDIS thing either.
10. Reboot, check all working, make a new cup of tea to celebrate.

So, what was wrong? My guess is that my network is a little complicated and I had some old configuration around internet sharing and on the RNDIS gadget. When I cleaned up the old config, and stopped the VPNs etc. everything sprang into life. I would also say that I was a little quick to try to log in (natural impatience) and this meant that bonjour had not caught up with the adverts from the pi.

BTW, thanks for publishing this blog – Using the PI with OTG has transformed the way I do things when travelling.

not working on OS X 10.10.5 on the Macbook Air… configured the zero’s /boot/cmdline.txt and /boot/config.txt… zero boots fine, but is not assigned an IP address and is not accessible (Apple’s Bonjour is installed and running and remote login is enabled on OS X)

1. configure your Zero’s cmdline.txt and config.txt files
2. turn on File Sharing via System Preferences
3. ssh or sftp using pi@raspberrypi.local
4. if you have previously configured vncserver on your Zero, you can access the running VNC service with:

vnc://raspberrypi.local:5901

hope this helps! now my Zero is a fabulous little Python development platform!

In my own testing, enabling file sharing wasn’t needed to connect to a Pi Zero over SSH, or using SFTP given both of those rely on the services offered by the Pi side, so shouldn’t make any difference?
I just checked and my test machine running Mac OS does not have it enabled and works fine.

tks! will test on my system again and report back – a very nice feature indeed – quite remarkable … however, i did note that Internet access is not configured or assigned for the usb0 interface as the IP range is outside my router’s LAN addressing?

Yeah, the IP address for the usb0 interface *has* to be outside the range assigned by your router. If your computer has two interfaces (e.g. eth0 and usb0) in the same network-range, then it won’t know which interface to use when trying to reach a specific address. That’s why eth0 and usb0 have to be in different network ranges, and you need to use ‘internet sharing’ / bridging / etc. so your computer knows to route traffic from one network to the other.

A comment on the terminology, not on the advice:
That’s usually true if routing (with an exception for routing from some subnet to a ‘more specific subnet’ which some routers support, maybe not on the pi), but if you are bridging between two interfaces, then both interfaces can (and indeed must) be in the same subnet – that’s the very definition of bridging…

OK! tks for all the comments on this blog! i can confirm that File Sharing does *not* have to be enabled…

i should have paid more attention to an earlier comment regarding USB cabling – not all USB cables work! i found one that did work and it was a short, direct cable – no adapters or power switches attached – simply USB malemicro usb male

connection appears as “RNDIS/Ethernet Gadget” under System Preferences->Network… using DHCP, it is assigned 169.254.188.244… i then ssh in using:

Can anyone point me in the right direction to be able to SSH into the zero if i already have another (or several?) devices on my network that identify as raspberrypi.local (presumably the default for all Pis?)

Well, one simple option is to disable your other network connection, ssh into the connected Pi Zero and grab its IP address, then simply use it when you reconnect your networking. Or you could disable other network connections, ssh into Pi and change its hostname?

Pi-Zero working fine to screen/keybd/mouse but can’t get this neat USB link to go. Using XP with Bonjour installed and PZ shows up on XP as Local Area Connection icon but with a yellow triangle and ‘limited or no connectivity’. Tried different cable, tried updating driver but when I use Putty to raspberrypi.local on port 22 Putty times out. If I try to connect to the IP address that shows up for the RNDIS Gadget I get an immediate ‘connection refused’.

I believe the IP address that shows up for the RNDIS Gadget is the address of the PC-side of the USB-networking connection. And as you’re not running an SSH server on your PC, that’s why you get ‘connection refused’. You actually need to connect to the IP address on the PiZero-side of the USB-networking connection, which will be different.
But if raspberrypi.local isn’t working, then I don’t know how else you’d discover what IP address the Zero got assigned. And I don’t have any systems still running WinXP that I could use to investigate further. The ‘limited or no connectivity’ probably just means that the USB-network connection doesn’t have an onward connection to the internet (which is obviously to be expected!).

An easy answer to the question of what IP got assigned is to use “ANGRY IP” (AngryIP.org). This is a must have tool for dealing with networks that use DHCP. it will provide a list of the connected ethernet adaptors that can be used to scan for any devices on the address range assigned to that adaptor. very quick and easy. Hope this helps someone

Sounds like in all cases the PC itself is trying to get an IP address via DHCP from the USB-network connection (which won’t work, as the PiZero isn’t running a DHCP server).
This isn’t what you want though, you want the PC to auto-assign a link-local IP address (169.254.x.y) to the USB network device.
For Ubuntu specifically (I’ve not experimented with Windows yet) see my comment from 2nd June about configuring “Link-Local only”.

Andrew: Just followed instructions in your 2nd June post but found no improvement with ssh.
I then did a reboot and modified the network ip4 setting again, and I can get in!
And I can also see the ip address, 169.254.238.187 (for me) – so plugged PZ into XP system, manually set that IP, and Putty now connects to pi@raspberrypi.local on port 22!
Then tried with Win10 machine and after manually assigning the IP address again I can get in using Putty with pi@raspberrypi.local.

Excellent! I now have a single cable link to PiZero on three different bases.

It works fine on my PC running windows 10!
but if i try to ssh on my laptop (i’m running opensuse leap)
it only says could not resolve hostname…
i’m pretty new at Linux and it would be great if someone could help me out here

I’m a complete newbie on Ubuntu but looking at the Connection Information dialogs, I replaced
PC_ZERO_DEV=usb0
with
PC_ZERO_DEV=enp0s26f7u1
and that seems to work. I can now ping 8.8.8.8 from via ssh on my Zero. I suppose the real test is apt-get update. 🙂

Glad you got it sorted! I guess things must work differently on the Ubuntu 16.04 you’re using, to the Ubuntu 14.04 that I’m using. Maybe I’ll try testing with a LiveUSB boot of Ubuntu 16.04 at some point… 😉

Something still not quite right. I can stop and start the pi, disconnect it, reconnect it and it sees the internet just fine. But if the laptop goes to sleep or restarts or powers off and on then the network is not visible to the pi any longer.

The two commented-out commands (sysctl and iptables) at the top of my script need to be run on your laptop after every reboot, as their effect is only temporary. I didn’t get round to looking into how to make them “sticky”.

I must confess it is my first RPi experience, I got my RPi zero for a fun-project and stumbled instantaneously when my usb router didn’t work with Pi. I could not connect neither mouse nor keyboard to it. So I found your solution, every basic operation was unknown to me, so even making SSH work was a victory, then virtual desktop was another victory. It works now!

My question to you, is how to make RPi connect to internet as well as being hooked via virtual desktop to my laptop. Is it possible to somehow share internet from laptop to RPi??? Or I have to use usb hub anyway to hook a wi-fi dongle???

It is very possible to forward it, with Mac OS, you just use Internet Sharing from the Sharing section in System Preferences. For Windows, am not sure though, a few people though I believe have documented it in the comments below.

For those running a recent flavor of Ubuntu a few more pointers to set this up nicely:
– In the Network Manager for the wired connection, under IPv4 set “Method:” to “Shared to other computers” in other to let your computer give an IP address to the zero and share the internet connection of your computer. Of course this is possible to configure for yourself, but this one-click option is very nice to have.
– Each reboot the zero will have a new MAC-address, showing up as a new wired connection in the network manager, requiring to do the configuration once again. To solve this, we can add some more parameters to cmdline.txt. First look up the current MAC addresses:
“$ dmesg -T | grep MAC”
Now add to the end of cmdline.txt:
“g_ether.host_addr=xx:xx:xx:xx:xx:xx g_ether.dev_addr=xx:xx:xx:xx:xx:xx”
Of course replacing the xx’s with the found mac addresses. Now your pi will always show up as the same device and be automatically bridged to the internet connection of your computer.

Thanks for posting this guide. I tried it on my new raspberry pi zero and it seems to work fine until the very last step.

My machine: windows 7 with itunes installed

I followed all the steps, and at the very end I *am* able to ssh to raspberypi.local using the command “ssh pi@raspberrypi.local“. However it doesn’t seem to accept the default password! The default password should of course be “raspberry”, but it always says Permission denied, please try again.

Just got my Pi zero connected directly to wifi network. Followed all instructions as above but usb Ethernet was showing as no ip. I was checking to see if connecting directly to wifi will work and it worked, i used one of those usb wifi adapter with micro usb to usb otg. BTW I was using Jessie lite.

Great blog! USB connection from PC to Zero is exactly what I need, but I’m getting :
RNDIS/Ethernet Gadget – no driver found

on Windows 8, do I need Win 10?

(I checked, Bonjour is running, double-checked config file edits. Got a dev friend at work to try connecting from his Linux machine, using avahi he could see it, but could not ssh. Avahi showed only IPv6, not v4, could this be an issue?

It worked. I ssh’ed into the Pi Zero from my windows machine and installed xrdp. Once done I disconnected from the usb and connected it to my P1 3. I installed Remmina on it to connect to the raspbian desktop on the Pi Zero. Don’t know what purpose it word serve but it’s possible.

I’ve tried connecting to `raspberrypi.local` and to `169.254.64.64`. Neither work. I’m plugging in to the ‘USB’ port (J10) and using a cable that transmits data on other devices.

Any suggestions? Are there any other “zero console access needed” things to do? The older methods had configuration on the OS itself, not just the boot partition. I don’t see that any other gadget modules are possible without console access.

I went into this blind and followed the directions to no avail, until today.

I see several posts by with people describing very similar issues so I thought I’d publish my foolishness.

My environment is a Windows 10 host running Ubuntu 14.04 as a guest VM. When I plug the pizero into a USB port the VM manager lists it under removable devices. In this case it shows up as Netchip RNDIS/Ethernet Gadget. …. all good so far.

From a linux shell I can see the interface for usb0 with mac address for IPv4 and IPv6…. again all good so far.

Now I’m confused and ended up wasting a bunch of time wondering why the default password for raspbian isn’t work… cursing a lot… wishing I’d gotten more than 4 hours sleep in the last 24… etc

Keep in mind I have lots of Pi’s… this was just the first zero and I was trying to keep it to a single cable 😉

Went to bed, got 8 hours this time and setup a FTDI console to so I could check the security logs on the PIzero….
after a couple more failed attempts and NO logs produced, it was clear I was doing something wrong….

The punchline:
Thinking the USB0 interface on my Ubuntu machine was where I needed the IP was my mistake… rather I needed the Ipv6 address or IP address from the PI side! For whatever reason and I really don’t care why, raspberrypi.local just wasn’t created… all I had to do was add an entry to /etc/hosts for it using the IP from the PIzero.

Now this does beg the question as to how you get the PI ip when you can’t log in to the device in the first place, but I digress. if I’d been thinking day I’d have saved myself a lot of aggravation… there are simple ways to scan for ips that I’ll leave for people to google if needed.

Last thought…. in my first attempts the ping6 worked… ssh was attempting to connect to something… the answer is simple, usb0 was a loopback to my ubuntu vm! Thank god I didn’t have a local pi user… that would have really blown my mind.

Long story short, I finally got this to work. 1) MUST use the usb slot nearest the HDMI slot. The other one only implements power, no data. 2) At least on my Win10 portable, it is actually sensitive to which USB socket on the PC that I connect the Pi to. One works, two don’t. (Different internal hubs).
Since I already had a Pi connected on a shared connection using 192.168.137 on the wired ether interface, the Zero was assigned an address in the 169.254 space. It has a connection to the PC; I haven’t yet tried sharing to it. Hopefully I can share to both pi’s.

This worked great except for one problem, my computer wasn’t recognizing the Pi by its hostname “raspberrypi.local” when attempting to connect via SSH (I am using Ubuntu 16.04 LTS). An easy fix was to go into my connection settings for the Pi (Recognized as wired/ethernet connection #3) and change the IPv4 connection settings to “Local-link only”. After that, SSH was cake. However if you have the IP of the Pi upfront you may not need to change the connection settings what so ever. Now that I am writing this post I realize that I could have just found the IP address of the Pi in connection settings and SSHed to that address. I guess whatever floats your boat (or just works). Hope my comment can be of use!!!

I’m on ubuntu 16.04 and it didn’t work for me.
The network manager was trying to connect to the raspberry pi without success… BUT I read the comment of AndrewS (2 June) and followed its instructions. It works like a charm now.

I’ve had mostly success with this approach. The first thing worth mentioning is that Ubuntu 16.04.1’s Network Manager seems to have automated much of this (port forwarding, IP masquerading etc). I initially used Ubuntu 14.04 and followed the stated procedures to manually configure both the host PC and the PiZ. That all worked. I had a 16.04.1 PC sitting idly nearby, and I decided to give it a try also. I should first mention the PiZ had the ‘config.txt’ & ‘cmdline.txt’ changes (including fixed MAC addresses) done at this point. The ease of the 16.04 configuration was amazing!!!
1.) Plug in the PiZ, after 10-15s the net-manager attempts to connect (propagating radio waves).
2.) Click the net-manager icon & select ‘Edit Connections’. Choose the latest wired connection; select the IPv4 tab; select “share with other computers”. Make any other desired changes and save this & within several seconds the connection is established. The net-manager makes all the IP forwarding and masquerading changes (Do a ‘iptables -L -x’ before/after connectiong if in doubt). It also creates a ‘10.42.0.0/24’ subnet for the first device, a ‘10.42.1.0/24’ for a second PiZ. (These subnets will be troublesome later on…)
3.) From a terminal on the host, SSH login to the PiZ.
$> ssh raspberrybi.local -l (pi, or your user account)
4.) You’ll be asked for a password (‘raspberry’ in the case of ‘pi’)
– at this point you’ll be in. DNS and routes will be working!
5.) To test DNS, ‘ $> ping google.com’. It should be working. ‘apt-get’ etc should also work. You should be able to ping other devices on your local LAN.
—- What’s NOT possible —-
I’m not a networking expert so perhaps there a work-arounds for this issues.
a.) Since the PiZ subnets are unique (10.42.0/16) they will not play with devices on your LAN (192.168.0.0/24) I added routes on the ‘192.168’ subnet devices to allow ‘10.42/24 access’ – but I cannot ping into a Piz from a 192.168 machine.
I can ping a 192.168 device from the PiZ – but that’s port forwarding and/or masquerading at work.

— Does anyone believe it’s possible to access a PiZ that’s running ‘ethernet USB’ from another local LAN machine?
(other than the machine it’s USB connection is physically on)
Many thanks.

Just got this working on Windows 10. Didn’t work at first, rebooted the pi with a keyboard, I checked “ip addr” is showing a usb0 network device, so it’s definitely ready to go. So plugged in back into the PC and ssh into it with Putty without a problem, maybe it just need some time to sort out DHCP, I don’t know.

Anyway, ssh’d in and realised the pi could not get online, so back to Windows and created a bridged connection between the RNDIS adapter and my normal LAN adapter.

Go here:
Control Panel\Network and Internet\Network Connections

Then highlight the two adapters you want to bridge, right click and create a bridge connection, that’s it.

The pi then took a couple of minutes to pick up a new ip address from the router, and is now part of my LAN. I can get online to update packages.

A question: If you use this to set up a Rpi Zero, and then wish to use the Rpi Zero headless, but connected via the network (e.g. disconnect the USB cable to the PC, and connect a WiFi dongle instead), is it necessary to reverse any of the extra settings in order to have the WiFi dongle (or ethernet dongle) work? Can you leave the network-over-USB config in place, and still have the Zero recognize and use a different network device if you disconnect the PC and instead plug in the network device, or do you have to reverse the network-over-USB config?

Yip, you don’t need to do anything to still allow USB to work as normal. But is worth keeping in mind is using the DWC2 driver, instead of the more optimised driver the Pi Foundation has been working on over past few years. So it will be work fine, but may not be as fast.

So, if network speed once headless is a concern, we’ll want to disable DWC2 before going headless. Is it necessary to back the changes out of both files, or will backing out just one get DWC2 out of the way (just in case we want to make it a tad easier to get back to USB network mode in case something goes wrong in headless mode)?

Hi-
I have got this working on Win10 but, getting to work on my Mac OsX Sierra laptop is a failure so far.
I made the two file changes (and confirmed it working on Win10; note: it only works in the USB nearest mini-HDMI, but you knew that).
When I plug it into my make: tried to ssh or ping raspberrypi.local, but no one home.
I was able to detect that it connects as a gadget using the (built-in) Network Utility. In the “info” tab, up pops “RNDIS/Ethernet gadget (en8)”. It lists the hardware address but, the ip address is blank 🙁 . Curiously, unplugging and re-plugging, it comes up with a different hardware address each time.
Further, I used Bonjour Browser (http://tildesoft.com/) and found lots of Bonjour services (this will be useful!) but alas, no raspberrypi.local

Got this working well with Ubuntu 16.04.
Not so good with Ubuntu 16.10, could only SSH when I found the zero’s IPV4 address and no zero internet access via the PC.
Would love to get it working with a Chromebook if anyone has any ideas?

@Scott Schulz No, I didn’t install any special software for this, and my Mac was running OS X El Capitan. I used TextEdit to edit the config files (don’t know if that could make a difference). Are you sure you connected the Pi Zero via its USB port (not PWR)?

@Arvid Kongstad Well, initially I was, but caught that pretty quick. I spent two days messing with the crazy thing: rewrote the card several times, checked the config files (using vim), tried it on Mac and Linux, and then… finally looked at the tag on the USB cable and realized it came with a gunlight, doh! That cable was intended for charging flashlights, and apparently only has the power leads wired up. So I went out and got another cable, and bingo! So thanks for the pointers, and thanks to OP for this post!

Hello, I have a problem. I’m able to connect the pi zero on my ubuntu laptop, I have the IP both in Link-Local and shared with other computer mode, but when i try to connect via ssh it gives me “connection refused: port 22”, It seems to me the the port 22 is closed or something like this. I tried with other port with the same results.

Andy,
thanks for your work. Though I had notice a problem on one of my pcs with this configuration. I could make it work only when powering up the Raspi Zero beforehand. If I didn’t power up beforehand and connect only directly through USB I receive the warning “USB Device not recognized”. After a huge search I found a possible solution:

@nicolas: Same here, I can’t get it working and tried on two Windows 10 x64 PCs. Shows up as Serial USB Device (COM3). In the Model-Field it states RDNIS/Ethernet Gadget, but that’s it. Not virtual network adapter.

For those that only get the USB Serial COM3 with Windows 10, go to the Device manager, right click on this USB Serial device and select Update Driver. Select Windows should automatically install the best driver. It will then download and install the USB Ethernet/RNDIS Gadget driver. Tested on the latest fast ring build 14971, but should work on others.

@ Rick:
I also tried updating the driver but it didn’t work on my Windows 10 64-bit. It didn’t find any suitable RDNIS-Drivers. Also I don’t want to install non standard drivers because I want to use the pi on multiple non-configured pcs.

Is there a way to use pi zero as virtual network interface on all Windows 10 installations?

I’ve plugged this in to moth my Mac book and windows computer. My Mac it comes up in network connections with a IP address. But it says can’t connect on both my windows and Mac On my windows computer it keeps trying to install the device. Any help??

So I’ve gone through these instructions and Adafruits instructions and cannot get this to work. I even tried downloading OpenSSH to make sure Putty wasn’t messing with me. I have Bonjour installed, I have shared teh pi with my WiFI conncetion, I have made sure I have the latest drivers. The pi has a set IP. I have tried connecting SSH to raspberrypi.local, pi@raspberry.local, the ip address alone. I have tried redoing the sd card. I must be missing something. Anybody got a hawkeyes view of what it is?

After some trouble with the driver for Ethernet gadget that was missing and which my Win 7 could not find by itself, I found instructions on the Web where to find it and how to install it. I then ran “ping raspberrypi.local -4” on Windows command line and got a reply from 169.254.114.213 (I saw somebody above also getting a 169.254 address from the Pi). So this must be the address of the Pi. I made sure that this is the Pi Zero I am talking to by disconnecting WiFi and LAN adaptor – and yes, this was the Pi Zero as I still got response to the ping. To make double sure I disconnected the Pi – and the responses to ping stopped. It was the Pi all right. I reconnected and got the ping response again.

I then ran ipconfig in Windows and saw that the address of my PC on this interface is 169.254.114.148, net mask 255.255.0.0. Moreover, I checked the ipv4 properties of the interface and saw that my PC is configured as a DHCP client on this network. So I assumed that the Pi acts as the DHCP server, which seems logical given that my PC is a client and that the address my PC has on the interface is in the same subnet as the address of the Pi. So far so good.

However, when I tried to use Putty to ssh into raspberrypi.local :22 it did not work – the Pi did not respond at all. I tried the numeric 169.254.114.213:22 – same result. I tried to use WinSCP to do SFTP into the Pi – refused to connect, saying that the host does not listen to SFTP but listens to FTP. Tried to connect with FTP – no joy.

To summarize, the Pi returns a ping but refuses to talk ssh and sftp. Please help!!

I have a problem with g_mass_storage module at Raspberry Pi Zero. When i connect with PC, Windows does not recognize and appears “Unknown Device” and with others and other devices with usb does not recognize too. I tried with g_multi too, I followed several tutorials on the internet and it did not work.

I do not think I was that clear. When I connect the raspberry pi as mass storage to another device that has usb (eg small sound box) it does not recognize and can not connect and communicate. The usb ports on the notebook are working normally. Do not you have a video of that part of the setup? Thank you

After doing every steps as explained (modifying config.txt and cmdline.txt, enabling ssh, checking USB cable, using correct USB port on RPi Zero, checking Bonjour service is running, enabling a shared internet connection with the Pi, trying different USB port on the computer), my RPi Zero has never been detected by the computer as a “USB Ethernet/RDNIS Gadget”.
I bought another RPi Zero, used same SD card, plugged it in and magic it was directly detected as a “USB Ethernet/RDNIS Gadget” which allowed me to connect with Putty through ssh and raspberrypi.local!
I guess there is a hardware issue with my first RPi Zero…so as it costs 5$, don’t spend too much time trying to connect it via USB and get another one!;)
I bought both my RPi Zero on The Pi Hut and ran Raspbian Jessie Lite (2016-11-25).

I had everything setup and working correctly until I got to the part where I ping google from my pi zero. It would ping successfully but when I went to do “sudo apt update” or “sudo apt upgrade” it would just hang there. It took me a while to figure out but it was my firewall on my pc. Disabled it and voila everything is working!

USB hubs only work when the USB port is working in host/master mode – they don’t work when the USB port is working in device/slave mode. This is why the USB OTG only works on the PiZero and not the Model B Pis, as the model B Pis already include a built-in USB hub (forcing them into master mode).

I would just like to say a HUGE thank-you to Andrew for sharing this. I finally decided it was time to do something with a Zero I bought a LONG time ago (a PiHut Zero Essentials kit version) and to cut a long story short, couldn’t get any peripherals to work – I could see it booting up OK, but couldn’t get a keyboard to work, or a USB wifi dongle, so was pretty much stuck. The only suspicious thing in common was the “OTG USB” cable was the one that came with the kit, and the only thing I had that I could use to attach the keyboard/Wifi. So, after a bit of hunting around, I came across this post, and less than 30 minutes later I’m posting this thank-you as I watch “apt-upgrade” messages fly past in a terminal window on my iMac with a working Pi Zero attached to a USB hub on the Mac.
Many thanks Andrew, hugely appreciated.
Simon

I had the same problem and I was only able to ssh by specifying the IPv6 address of the Pi, and the connection only lasted a few minutes. After a few days of trying everything I found on the internet with no results, I managed to make it work by chance, and actually the solution is pretty simple.

As you say, a USB network interface shows up if you click on the network icon on Ubuntu. You have to click on edit connections, select the USB network connection and click edit. On that window, go to the IPv4 tab and on method, select “Shared to other computers”. You can do the same on the IPv6 tab. Wait a little bit until a connection is established and a IPv4 address is assigned to your Pi, and then you should be able to ssh through USB with “ssh pi@raspberrypi.local“. Every time you unplug and plug the Pi again, you have to do the above steps. I don’t know if there is a way to automate this, that’s the next thing I want to try. I hope it works for you, it worked for me.

Sorry, the method is not “Shared to other computers” but “Link-Local only”, as some answers above suggest. I’m not on an Ubuntu machine right now so I’ve couldn’t check if what I was saying was correct.

Yea as above, struggling to get it working with the new RPi Zero W.
Not getting it show up as an adapter in Win10 like my other 4 RPi Zero’s do 🙁
Perhaps something was changed to accomodate the Wifi functionality preventing the nice OTG gadget bits working.

Does this still work with pi zero v1.3 (camera)? I have been trying for weeks and have used numerous guides and still can’t ssh or vnc into the zero via usb. So far usb-serial has been the only way I can connect to it. My searching shows me there are alot of others in the same boat with the v1.3. I have even used every image from the current to the beginning of may 2016.

AFAIK it would only “get confused with other interfaces” if you have the same subnet (e.g. 192.168.1.*) assigned to multiple interfaces.
Although if you have two separate interfaces each configured to the link-local 169.254.*.* range, then I wonder if that might confuse things?

Tried this on different pi zeros (zero v1.3 (x3) & zero W v1.1), different OSs (NOOBs & Raspbian Jessie) and different computers (PCs with W7/W10 and RedHat), no luck. It is not ‘simple’.

RedHat sees all of the zeros, and even sees their mac addresses, but cannot connect.
Windows 7 sees the zero but gets a driver error
Windows 10 sees the zero, got a driver error initially, but wouldn’t connect.

Oh, and before someone mentions it, no it isn’t the USB lead – tried several… .

I tried this with 5 Raspberry Pi Zeros (v1.3 & ‘Wv1.1), clean installs, etc, etc, but to no avail. However, I did manage to communicate via the serial Rx/Tx, so that at least worked.

I finally got things working by:
i) installing Bonjour (I guess those with iTunes installed already had it – which probably explains why it worked for some, not for others).
ii) boot the Pi from an external power source before connecting the data USB (I did check whether there would be a conflict of power but it appears that as soon as power is detected on the data USB the power drawn on the power USB drops to zero).

Tried this out on a PiZ and W10 and then on my PiZW , using just the usb link (ie piowered via the usb from my laptop). Worked a treat!
I’m in an AirBNB at the moment with wifi, and using the usb link to fire up the PiZW made getting its ip address a doddle. And it will save a lot of faff in the future.
Very many thanks for this technique.

Followed these instructions and checked several times, using Ubuntu 17.04. It shows up in my connections, but not when I use nmap, and all the ssh methods I’ve used fail to find it. I’ve also tried to ssh pi@ all the IPs returned by nmap to be sure. Is it potentially under some name besides raspberrypi.local? Or is there possibly some conflict with my newer Ubuntu or Raspbian?

So im slow…. spent all day trouble shooting and finally decided to try a different cord….. turns out that I was using a power only cord. So if any one just cant get it to work try using the cord to plug your phone in. if it just charges and doesnt make any sounds its the wrong kind. Pretty obvious i know but its easy to assume.

Thanks for the tutorial, once i got past my personal issues it worked great!

Unfortunately the same system can’t work for the Pi3, as it has the USB/Ethernet chip in the way. It only really works on the Pi Zero, as the processor can directly talk to the device on the other end of the USB cable.

I have a big problem and i don’t know if it’s possible to solve it, i can’t write file from computer into pi zero when g_mass_storage it’s working, i wan’t to use raspberry as usb pen drive to transfer information in both sides but in all cases the pi zero appears as read-only into OS

It’s possible change that? I know with this is possible the SD Card damage because receive corrupt information

Hi! Excellent guide!
I was using your guide to ssh into my Raspberry Pi Zero that had RetroPie image installed.
Couldn’t get it to connect via putty.
Found out that instead of using raspberrypi.local as the address.
The default when using retropie is retropie.local

Will this work with a Pi Zero W? If so, you have a use case where the Pi Zero W can run as a USB boot/install ‘pen drive’, being loaded with firmware over WiFi to the Pi Zero W and then presenting the image to the device to boot. Useful for hardware where the entire machine gets flashed/updated and an error can leave it completely isolated from any existing network and requiring ‘sneaker net’ to update the USB install image currently.

Sadly the end product was much less than exciting. It does work but it is very slow because although the Pi-W supports 802.11n, it only has one antenna so runs no quicker than 802.11g and that’s far too slow if copying lots of data. So whilst this could be a solution for a remote site, sneaker-net is much quicker for something close by :-(.

I’m trying to activate this option but no luck so far. I added ssh file to freshly etched sdcard for RPi 0WH, I modified config.txt on notepad++.
Bonjure and QuickTiem are instaled and still no connection and Win7 even don’t see the Pi in usb port.
So, what I’m doing wrong?

big big thank you to Andrew too, brought a Pi Zero W recently and was debating as how to connect it up. As a newbie both to the raspberry and rasbian(linux) i was worried. Ggoogle searches result in the ‘headless’ method, articles and several utube videos. Reading some of the replys/comments all i can say and in my exprience is be VERY careful you follow the instructions, the hacking (sorry editing!) of the two files is fundemental and you must GET RIGHT also the adding of a blank shh file. Now have a Pi zero sitting on my desk connected to a usb port on my win7 pc. i can shh into it using putty 🙂

So I have been utilizing the USB gadget mode to create a portable USB webserver for work (which has been awesome!). At first I was having issues with the changing MAC addresses on reboot, which was solved partially by adding the “g_ether.host_addr” and “g_ether.dev_addr” to the cmdline.txt.

I say partially because the pi will still use a random MAC address if my desktop/laptop (both linux) have been rebooted since it was connected last. So everytime I reboot one of my linux host machines I have to:
– connect my raspberry pi (it will use a random MAC)
– unplug the pi
– reconnect the raspberry pi (then it uses the hard coded MAC)

I feel like I have tried everything but no matter what the pi will still use the random MAC on the first connect after a host reboot. I tested this on windows and this doesn’t happen, so it seems to just be a linux thing. If anyone has any ideas it would be greatly appreciated!

(for the record I tested it on Ubuntu, Debian, and Manjaro and got the same results).

Hi i am facing problem for connecting raspberry pi 0 with ubuntu Machine using usb(virtual ethernet). i have connected my device with raspberry pi 0 with Ubuntu machine and i found RNDIS host driver is not getting load using “cat /sys/kernel/debug/usb/devices”. So I have check kernel messsage using dmesg command and i observe that host driver got fail while probe. Below are error logs. Request you to provide help for same.

Just today I ran into this situation and spent way too much time solving it, so thought I would share and hopefully help someone else out.

I’m running OpenSUSE Leap 15 (OSL 15) and was attempting to connect the Pi Zero W using a Stretch lite image. Connecting was not a problem, and was able to see the new interface labeled usb0. Addressing, on the other hand, was the problem. What I found is that avahi is (now) responsible for link-local addressing; DHCP is not.

I am not using Network Manager with OSL 15, so used YAST to change the dynamic addressing mechanism from:
“dhcp” to “zeroconf”
There’s also “dhcp+zeroconf” which should also work since there’s no dhcp on that usb0 link. Under the covers this tweaks the ifcfg-usb0 file found below /etc/sysconfig (on most rpm-based distros) from:
“dhcp” to “autoip”
(or “dhcp+autoip” for dhcp+zeroconf)

Once completed I had the familiar 169.254.0.0/16 address and “avahi-browse -a” showed services over usb0. From there, raspberrypi.local resolved and I had no issue connecting.

Hi,
I’ve done everything as explained in the post but i’m having some issues. As soon as i connect the Raspberry Pi Zero to my W10 computer it recognises it as Ethernet Usb RNDIS device and starts installing the drivers, but after instalation it appears as Serial COM device so no network device appears between the adapters and I don’t know how to keep going. I’ve tried to reinstall the drivers but it says it’s everything OK.

BTW: I struggled with this guide with no success for a week, then I realized I was using two USB Power only cables!! You have to use an USB data cable. You can check the cable is data if connecting an android device it starts to ask how to connect the device.

I tried to use the procedure described : installation of raspbian buster lite, modification of config.txt and cmdline.txt and creation of ssh file without extention. Then I insert the SD card on the raspberry pi 1.3 and connect it using micro usb-usb cable to mac os. However the raspberry is nto detected by mac. Any idea why? does the procedure work with raspbian buster lite? should I use otg cable ? Many thanks for your support