is 2 computers "sharing" an X Server possible?

MaxiMal_98

New Member
Joined
Nov 23, 2020
Messages
5
Reaction score
1
Credits
49
is it possible to have one computer running an X Server and connecting to it and another computer (connected via LAN or something) also connecting so you can run one app on one computer while you can run another on the second.
okay so you might think: why would you want to do that? well cluster computers like for example two raspberry pis would then maybe sort of but not be able to be used as one computer.
that is all.
 


Yes, you can but it's not like sharing an X server, but redirecting the X protocol's input (keyboard and mouse) and output (Window drawing) between an application executing at a remote computer, and the X server of the computer you're sitting at.

TL;DR: You need to SSH to the second computer establishing an X tunnel.

For example, you're sitting in PI1, and you want to run some apps at PI2, but seeing their graphical output in your local computer, PI1. I will use scratch as an example.

Imagine that your PI2 is at 192.168.0.11.

You'd do this:

Bash:
pi@pi1:~ $ ssh -XY [email protected]
[email protected]'s password: *******
Linux raspberrypi 5.4.72-v7l+ #1356 SMP Thu Oct 22 13:57:51 BST 2020 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Dec  9 13:56:10 2020 from 192.168.0.132

Wi-Fi is currently blocked by rfkill.
Use raspi-config to set the country before use.

pi@pi2:~ $ scratch

Then you would see the scratch window in PI1, while it's running on PI2.

if it fails, try the following command first:
Bash:
pi@pi1:~ $ xhost +
access control disabled, clients can connect from any host

What did we do here?
  1. xhost + enables applications in other hosts (in any host) to connect to our local X server to display graphics on, and to accept input from. That enables our computer as an X terminal for other hosts' applications.
  2. ssh -XY user@computer establishes a SSH session which will tunnel the X protocol to our local server.
You can do this with as many Raspberry Pi (or servers) you'd have into your local network, distributing your workload across the network as needed.

It will normally work without the xhost + before, if the default configuration of your computers is friendly enough. I just tried, and I can do X forwarding from my Raspberry Pi, that usually runs pihole but has a full Raspbian, to my laptop running Manjaro, without running the xhost + before.

You can do the above even if someone else is using the other Raspberry Pi (or computer) interactively, as Linux is multi-user. Back in the days at the uni the labs were easily overcrowded, so I usually did this to use a lab's linux computer, from the library, at the same time someone else was working on it. As long as your fellow student didn't reboot the computer, those machines could easily handle a student on-site, and at least other two remotely to do things like network programming and Octave simulations (and they were 16 MB Pentium II, in 1998-2000).
 
Last edited:
Or you could use an app like KRDC (OK, that's the KDE app, there are others out there) to simply mirror the whole desktop easily. This has the bonus of working with other OSes: I know for a fact that Windows (at least the pro version) supports Remote Desktop Connection, and I imagine that Macs can be set up to use a similar protocol.
 
I use VNC, specifically x11vnc, and do computationally expensive things on a different computer than the one I'm using. I use RealVNC Viewer to see the desktop of the remote computer and do the work through it.

I've been doing this for a long, long time. It just works for me. Right now, I have six virtual machines running that I can access. Exactly none of them are on this computer.
 
Remote desktop is OK for some things, and very handy as everybody knows. But X tunneling is far lighter, built-in by default literally everywhere and since forever, and uses the least amount of network resources and graphical memory on your terminal computer.

You can also do the X11 tunneling from a Windows client if you install an X11 server, for example using Cygwin-X.
 
  • Like
Reactions: Rob

Members online


Latest posts

Top