SSH into Pi Zero over USB

When you first get a Pi Zero the big question is – how do you access it?  You can get a powered USB hub, USB keyboard, USB mouse and HDMI adapter. Or you can just plug it into your computer directly and access it over USB using ssh.

These instructions are for a Raspian Jessie image that I downloaded from here:

I’m using the full desktop image version 4.4 from May 27, 2016.

Update: I’ve also managed to do this with the lite version.

Here are my notes from walking through the process. You can find links to the original instructions in the References section below.

Hack the Image

To access the Pi Zero over USB you have to hack the image first.

  • If you have the SD card in your Pi Zero, power it down and remove it
  • Put the SD card in an adapter and plug it into your computer
  • On a Mac the SD card should appear on your desktop
  • Open the SD card icon to explore the contents

Hack config.txt

  • In the root folder of the SD card, open config.txt in a text editor
  • Append this line to the bottom of it:
  • Save the file

Hack cmdline.txt

  • In the root folder of the SD card, open cmdline.txt in a text editor
  • After rootwait, append this text leaving only one space between rootwait and the new text (otherwise it might not be parsed correctly):
  • Save the file

Update: On a fresh image that has never been booted, you may see extra text after rootwait. But if you boot the pi from the disk at least once, that extra text may go away – taking your new text with it and you won’t be able to connect!  Easiest solution: boot the pi at least once with the disk before making this change.  Inserting the new text between rootwait and the other text preserved it – but I couldn’t login to it.  So to reiterate: boot disk once in pi, add new text in cmdline.txt, then try again.

Boot the Pi Zero

  • Put the SD card into the Pi Zero
  • Plug a Micro-USB cable into the data/peripherals port (the one closest to the center of the board – see picture above)
  • You do NOT need to plug in external power – it will get it from your computer
  • Plug the other end into a USB port on your computer
  • Give the Pi Zero plenty of time to bootup (can take as much as 90 seconds – or more)

Login over USB

This part assumes that ssh access is enabled by default in your image and that the default user is pi with a password of raspberry.

  • Open up a terminal window
  • Type the following:
       ssh pi@raspberrypi.local
  • If prompted with a warning just hit enter to accept the default (Yes)
  • Type in the password – by default this is raspberry

Update:  If you try this again with a new image, you may get a warning about spoofing and the ssh login will fail. In that case you need to remove old ssh keys referring to raspberrypi.local by doing this:

    ssh-keygen -R raspberrypi.local

After that, try the ssh command again and it should work.

Congratulations! You can now access your Pi Zero with just a USB cable.


Mitch Allen is a game developer, tech writer and robot maker. To download his latest games and books please visit his Web site at