0

I am a linux newbie who just got his second linux machine running in room! I understand that I can use one to control another via ssh, but it should be faster to use real cables, eg USB cable if possible. Soon, I will have a raspi with linux. If there's a way to do it, it would be awesome!

Question

Is it possible to connect two linux machine over a USB cable, controlling one from another as if using SSH? What are the possible difficulties? And why do people seem to not use this method?

5
  • 3
    Although you specifically ask for USB, I would like to point out that if both machines have a gigabit ethernet connector, you can connect them directly with a standard network cable without needing a hub/switch. – Jonas Berlin Oct 24 '19 at 6:09
  • 4
    Possible duplicate: unix.stackexchange.com/questions/195765/… – Jonas Berlin Oct 24 '19 at 6:33
  • 3
    Do NOT just plug them together! You could kill your hardware. – Panki Oct 24 '19 at 6:55
  • 2
    You seem to assume that connecting over usb is somehow faster than over ethernet (either wired or wireless) or that a usb cable is more "real" than an ethernet one. It's not. That being said, your raspberry probably implements OTG and can act as either a USB host or device (gadget), and can implement whatever USB interface you may like (eg. make it appear as a keyboard to the PC it's connected to). – pizdelect Oct 24 '19 at 10:27
  • Well.. I guess I was too ignorant to like ethernet cable.. now I know how valuable it is! – Student Oct 24 '19 at 12:20
4

Is it possible to connect two linux machine over a USB cable,

USB is an asymmetric protocol: You have a single host (the PC) at the center of the device tree, and many devices/clients. That's why have you USB-A (for the host) and USB-B (for the client) connectors. Unfortunately, the industry didn't follow this scheme, so there's an (unnecessary) wide variety of USB cables now.

You cannot directly connect two hosts together, that doesn't work, neither on the protocol level, nor electrically (and if you are unlucky, you'll fry the electronics this way).

That said, there are USB OTG ports (which can act both as host and client, but I've never seen one in a PC), and there's also an USB-C mode that in theory can connect hosts directly, but I doubt this is supported by the drivers, and I've never seen this working somewhere.

And why do people seem to not use this method?

Because it doesn't work. You can connect PCs directly with a LAN cable, or you can connect two Ethernet USB clients to each PC host port, and then connect the USB clients with a LAN cable. The "host-to-host USB cables" you can buy work this way, with the chips integrated into the cable.

TL;DR: Use either LAN or WLAN. It doesn't work with USB.

2

I can use one to control another via ssh, but it should be faster to use real cables, eg USB cable if possible.

SSH is a protocol. You still need to connect the two machine at a physical level, e.g. via Ethernet cable, Wi-Fi connection, or USB cable.

The last option is not recommended as USB cables carry voltage and you might easily end up frying the machine's USB chip.

You can connect the two machines directly via Ethernet cable and configure them with IP addresses in the same subnet, e.g.

  • machine A: 10.0.0.1, subnet 10.0.0.0/24
  • machine B: 10.0.0.2, subnet 10.0.0.0/24

After which, you can connect from A to B via SSH:

ssh user@10.0.0.2

Make sure a SSH server is running on B and accepts connections from A.

1
  • I did not even think about connecting them using a ether cable... thank you for pointing me out that method! If possible, would you mind providing slightly more details? – Student Oct 24 '19 at 12:22

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.