Pinterest Stumbleupon Whatsapp

The versatility of the Raspberry Pi means that at some point you’re bound to be using it outdoors, beyond the reach of your wireless network. So how can you communicate with it without plugging in a keyboard and monitor?

It goes without saying that lugging human input devices and displays around with you when isn’t practical. There’s the external power requirements of the display, for a start (unless you use a dedicated, portable Pi touchscreen display How to Setup Your Raspberry Pi Touchscreen How to Setup Your Raspberry Pi Touchscreen The Raspberry Pi comes with a variety of useful add-ons, but one piece of kit that has proved particularly popular is the Raspberry Pi 7-inch Touchscreen Display. Here's how to set one up. Read More , perhaps).

A better solution is to communicate via another device, such as a notebook PC. While Wi-Fi direct is currently unsupported by the Raspberry Pi, you still have two options for a direct SSH connection without a wireless network.

When You Might Use This

Wirelessly connecting to a Raspberry Pi — whether it has wireless networking enabled or is connected via Ethernet to your router — is certainly more convenient. It’s almost certainly the preferred option, whether you’re at home, at school, or at a maker event.

However, it isn’t ideal for every scenario.

raspberry pi zero comparison


For instance, if you’re using your Pi with the camera module, you may like to take it outside, perhaps to capture some time lapse photography. Without a wireless network to connect to your Pi via SSH, you’ll need another solution, something that will work via a PC or perhaps a mobile device.

That’s where a direct connection comes in. You have two reliable options here: Ethernet and USB.

Connect to Your Raspberry Pi via Ethernet

The most obvious option for such a connection is via Ethernet cable. All Raspberry Pi computers (save the Pi Zero Getting Started with Raspberry Pi Zero Getting Started with Raspberry Pi Zero Whether you bought a magazine with one glued to the front, or found a kit online, the chances are you're now the proud owner of a $5 computer: the Raspberry Pi Zero. Read More ) have Ethernet ports, making this the option that works best.

For this, you’ll need:

Standard Ethernet cables are fine here, as the Raspberry Pi can reconfigure the port. In times past, a crossover cable How To Make An Ethernet Cross-Over Cable How To Make An Ethernet Cross-Over Cable Ethernet cabling has been standard in networking installation for years. It’s the fastest way of connecting PCs together - to your router or a central switch. Sure, you could go wireless, but the truth is... Read More would have been used to connect two computers, but that isn’t necessary here.

You’ll need your Pi setup to accept SSH connections. This isn’t enabled by default, but there are two ways around this.

  1. Boot up with a keyboard and monitor to enable SSH via raspi-config What You Need to Know About Getting Started with Raspberry Pi What You Need to Know About Getting Started with Raspberry Pi The Raspberry Pi computer is the latest in a line of compact, multi-function devices, shipped as a barebones package so that end users can use the hardware for virtually any computing project that comes to... Read More .
  2. Insert the SD card into your PC, browse to /boot and create an empty file called ssh.

(This file is detected by the Raspbian operating system at boot, and takes it as an instruction to enable SSH.)

Everything you need to connect to the Pi via SSH is now in place. All you need is the device’s IP address. You can find this by connecting to your router (typically, but you’ll need to check the router for the correct IP) or by booting the Pi with a keyboard and monitor and entering


You’ll need to check that the Pi boots correctly before proceeding anyway, and that SSH works under normal circumstances. Our guide to connecting with SSH Setting Up Your Raspberry Pi For Headless Use With SSH Setting Up Your Raspberry Pi For Headless Use With SSH The Raspberry Pi can accept SSH commands when connected to a local network (either by Ethernet or Wi-Fi), enabling you to easily set it up. The benefits of SSH go beyond upsetting the daily screening... Read More will be useful here.

Once you’re satisfied the Pi boots and normal wireless activity via your router is satisfactory, shut down the device.

sudo shutdown

Now, connect your Raspberry Pi to your PC with an Ethernet cable.

Say Bonjour!

To get this to work, you’ll need a particular piece of software: Bonjour Zeroconf. This Apple software is a for network device recognition, and comes pre-installed in macOS. Windows users can install Bonjour Print Services v2.0.2 from the Apple website.

With this installed and the direct cable connection with your Pi established, once the little computer is powered on and fully booted, you should be able to connect.

However, patience is advised here. The Pi will first attempt to fetch an IP address from a DHCP server, then when it fails, default to private addressing in the range 169.254.x.x. You may also find it useful to switch to Airplane mode on your PC or laptop to ensure no confusion with other devices on the network. Once the IP is assigned, Bonjour networking establish the .local domain addressing.

After a short while, simply open your SSH tool and connect to raspberrypi.local (or pi@raspberrypi.local), with the default password “raspberry”.

Windows users may need to force the operating system to abandon the router-assigned IP address for this to work, however. This is easy enough to do by opening the Command Prompt The Windows Command Prompt: Simpler And More Useful Than You Think The Windows Command Prompt: Simpler And More Useful Than You Think The commands haven't always stayed the same, in fact some have been trashed while other newer commands came along, even with Windows 7 in fact. So, why would anyone want to bother clicking the start... Read More and typing:

ipconfig /renew

This will result in a random private IP in the 169.254.x.x range.

Connect Your PC to Raspberry Pi Zero via USB

If you have a Raspberry Pi Zero, you can also connect directly to it via your PC or laptop’s USB port, though this also requires Bonjour on Windows and Mac, or avahi-daemon on Linux (avahi-daemon is pre-installed with Ubuntu).

raspberry pi zero top

Begin with a fresh copy of Raspbian Jessie or Raspbian Jessie Lite (May 26th, 2016 or later) flashed to your SD card How To Install An Operating System To Your Raspberry Pi How To Install An Operating System To Your Raspberry Pi Here's how to get a new OS installed and running on your Pi – and how to clone your perfect setup for quick disaster recovery. Read More . Before inserting it into your Pi Zero, use your desktop file explorer to find the boot partition, and find config.txt. Open this in a raw text editor (such as Notepad on Windows) and scroll to the bottom. Right at the end, add:


Once you’ve done this, save and close the file, then find and open cmdline.txt. Find “rootwait” and insert this right after:


Ensure this is on the same line, separated only by a space, like this:

raspberry pi usb code

Save and close, then eject the microSD card. You can then insert it into your Raspberry Pi Zero and connect it to your PC before booting the device. The connection should be via USB.

Use raspberrypi.local as the address in your SSH software (again, you might also try pi@raspberrypi.local if using the Linux command line). Note that you may need to disable wireless networking if you have any other Raspberry Pi’s on your home network. This will ensure you connect to the Pi Zero over USB, rather than, say, your Kodi box The Easiest Raspberry Pi Media Centre, With RasPlex The Easiest Raspberry Pi Media Centre, With RasPlex Read More over Wi-Fi.

If you run into any problems, try switching your USB cables.

Two Reliable Direct Connections

It would be great if it was possible to connect via Bluetooth or wireless from a mobile device — perhaps Android or iOS — and while this is theoretically possible, it currently isn’t supported. While there are some accounts of either of these methods working, neither appears particularly reliable.

But we’ll be happy to hear from you if you have got either of those methods working reliably and can connect via SSH. Tell is in the comments about that, or any problems you run into!

Image Credit: goodcat via Shutterstock

  1. Daniel
    January 11, 2017 at 3:08 am

    But this is so complicated... And you need another computer to attach to it? Why not just hook it up to your phone through 802.11 to use something like juiceSSH and be done with it?, granted you are not going to be able to use your phones wifi but that's pretty much the point. The article was informative though, i didn't know you could use bonjour like that, thanks!

  2. luke
    January 9, 2017 at 6:12 pm

    I've been trying this for a while now, having a PiZero i've attempted the SSH-over-USB method a couple of times and have never had any luck. i think its something im doing wrong on the pc side of things, i've done the file edits correctly and re done them so many times i can remember them lines of code of by heart now haha!

    Anyway, i have Ubuntu 16.04, and have done the correct steps on the pi configuration, but when it comes to SSH'ing into the pi it never connects, always error messages, reckon ive missed a setting or something on my PC that was a requisite.

    any help appreciated :)

Leave a Reply

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