1

I remember that when starting with Pi a few years ago (see this 2.5 year old question), it was impossible to SSH the Pi (without screen / keyboard / mouse) from computer with a USB cable only.
One had to use an ethernet cable, set up a network using a router, etc. It has to be noted that direct connection PC <--> Pi with an ethernet cable, without router, is quite complex to set up (I lost a few hours about this with Windows...)

I've recently seen that, with another similar board (maybe CubieBoard or another one?), there was a very-simple-to-use direct connection PC <--> Pi with a single USB cable.

Is this available in a recent version of Raspberry Pi (i.e. RPI3) or with a specific version of Raspbian?

1

A direct data transfer connection to PCs via a single USB cable is only possible on the following models:

  • Raspberry Pi A
  • Raspberry Pi A+
  • Raspberry Pi Zero
  • Raspberry Pi Compute Module

All other models do not support USB device or USB-OTG slave mode. Please note that on all models except the Compute Modules and the Zero , it is impossible to transfer data over a Micro-USB port.

  • Thank you. As said in another comment, it is sad that RPi is late on this point... It is available on A, A+, Zero, and other boards, why not on RPi3 ;) ? I hope it'll be available on RPi4. – Basj Oct 5 '16 at 11:01
  • All other models habe an USB hub/Ethernet adaptor combo "in the middle" of such a direct connection which makes device mode impossible. – flakeshake Oct 5 '16 at 11:02
  • Why impossible? – Basj Oct 5 '16 at 11:03
  • Its an USB Hub , you can only conect multiple devices to an USB hub , not multiple USB hosts. You cannot conect two USB hosts together via an USB Hub either. – flakeshake Oct 5 '16 at 11:05
  • 1
    As said on most models the Micro-USB port is power (electricity) input only. The data lines are not connected ! – flakeshake Oct 5 '16 at 11:10
1

As the board is not electrically connected to the data lines of the USB, the micro USB port on most Pi models seems to be only usable for charging. However, you could rig up a USB based connection, using:

  • A USB to Serial adapter to the serial pins on the GPIO. Most adapters (I think I have successfully used the Adafruit one sold by ModMyPi) can also supply power via the GPIO, though this sort of isn't recommended as it bypasses the input fuse, so another USB cable can be used to provided power by USB (you will still need the ground connected to the serial adapter though). For instructions on interfacing this will help, but in short over this you can then do

    • A standard serial interface (this was supported in Raspbian images by default for all normal Pi models with the possible exception of Pi3) and then access a Linux console (Using a terminal client on a linux (and possibly Mac) clients, and in PuTTY on Windows clients)
    • Or via the Point-to-Point protocol, which basically emulates a network connection over the serial connection. Please note bandwidth is severely limited by the serial interfaces so transferring files via SFTP (and even large console messages) will be VERY slow. This also may be a pain to setup (even on a Linux client where it can be installed easily...) and the only vague benefit I found was to transfer files VERY slowly.
  • A USB-to-Ethernet adapter to a ethernet cable to the Pi's ethernet port (will likely require USB power still as AFAIK the Pi hasn't any Power over Ethernet capability). You don't have to use a gigabit adapter to do this, and also the computer connecting to the Pi should just see this as a extra network connection - you would still run into the connection issues you had with your computers normal Ethernet jack, but perhaps not as much as you can then use the normal connection to connect to the real Internet.

0

It is not possible (although it may be with Pi Zero or A+).

It is possible with an Ethernet cable see How do I set up networking/WiFi/Static IP - "Connecting a Computer to the Pi"

  • 2
    I do it with the Pi Zero all the time, but you're correct that this works only for the Zero and A+ (which support OTG). From freshly-flashed SD card, you only need to edit two config files on the boot partition. See gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a – BJ Black Oct 5 '16 at 10:02
  • I use it with Ethernet cable all the time (either with a router or direct to PC, with a tricky local DHCP server...). It works, but it is not trivial at all. Now we're in 2016, it would be time for such an easy USB-only solution in RPi3 or 4, etc., especially now that Zero or A+ or other boards have it! Such a shame RPi is late on this point! – Basj Oct 5 '16 at 10:59
  • @Basj No need for DHCP server, ssh works with a link-local address. Read the link. USB is not possible with Pi B et al because they have an on board hub. You need an OTG USB. – Milliways Oct 5 '16 at 11:26
0

The question you linked to is different from yours. They ask about a data connection via the charging port.

You don't mention that restriction in your question.

What you ask is possible. I have used it myself on a Pi 2 and Pi 3.

I've only tested it with an Android device, but there's no reason why you couldn't use a desktop PC running Windows, Linux, or OS X.

Edit /etc/network/interfaces and append these two lines:

auto usb0

iface usb0 inet dhcp

Then, on Android, I enable USB tethering and plug my phone into my Pi. My phone assigns my Pi an IP address, and I can then connect via SSH.

  • Actually, there is a reason why this wouldn't work with a PC. I don't recall of a single PC with a USB-OTG port. – Dmitry Grigoryev Jan 19 '17 at 11:30
  • The question makes no mention of OTG. It asks how to SSH via USB cable. I do that all the time from Android to Pi. Not sure why I got a downvote for that... – Aaron F Jan 19 '17 at 14:56
  • The question doesn't mention Android either. Android uses OTG, that's why SSH via USB works with Android. It won't work with a PC though. – Dmitry Grigoryev Jan 19 '17 at 15:21
0

Note: Apparently, this only works on Zero and A boards, not RPi 3, which is B.

With the microSD card in your computer, go to root folder of the boot volume and:

  1. add to config.txt:

    dtoverlay=dwc2
    
  2. append to the end of the line in cmdline.txt:

    modules-load=dwc2,g_ether
    
  3. create an empty ssh file to enable ssh

Then put the microSD in RPi, plug your USB cable to USB port (not PWR), wait a bit and then you should be able to ssh:

ssh pi@raspberrypi.local

Verified with RPi Zero W running Raspbian Stretch Lite.

All credit goes to https://www.thepolyglotdeveloper.com/2016/06/connect-raspberry-pi-zero-usb-cable-ssh/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.