Run application on local machine and show GUI on remote display

Variant A - Shooting X Windows to another DISPLAY:

  1. See to it, that the Xserver on your Laptop starts up listening to tcp connections. Sadly X11-Networking is disabled by default in most distributions. Since the Xserver is started by your display manager (gdm, lightdm) this has to be configured there:

    Whatever display manager you use, some configuration file in /etc/ will probably contain the responsible XServer parameter. Run grep -r 'nolisten tcp' /etc/ on your Laptop to find out which config file is responsible and remove the part where it says -nolisten tcp (not the entire line, just this parameter). Restart X on your Laptop.

    Your Laptop should now have a display running on tcp port 6000 (try running nmap -p6000 Laptop on your Desktop PC, if the port reported as "open", you came this far).

  2. Make your X-display available to the desktop computer. X11 uses an authentication mechanism to grant access to a display. You have to allow the desktop PC to shoot Windows onto the Laptop. Normally by exchanging a display cookie.

    For starters perform this step with hands on your notebook. Once you have gotten the concept with the DISPLAY variable and everything, you can do this via ssh.

    Quick and dirty: You can run xhost +desktops.computers.ip.address on your laptop to grant X access to the desktop computer. Note that every user on your laptops computer can use your laptops X display this way. Note that this is sufficient i.e. for installing a keylogger on your laptops display. Use this method only for testing.

    Correct and secure: run xauth extract cookie-file :0 on your laptop to export your display access secret to "cookie-file". Transfer the cookie to your Desktop machine. Run xauth merge cookie-file. Or in one short step (from your desktop) ssh Laptop xauth extract - :0 |xauth merge - Note: if your laptop and desktop are sharing a home directory i.e. via nfs you don't need to exchange any credentials. The credential database is the .Xauthority file in your home dir, and can be shared among different machines.

  3. Run the program: In a terminal on your desktop PC run export DISPLAY=Your.Laptops.IP.Address:0, run any X program in the same terminal. It should appear on the notebooks display.

Variant B - Using SSH with a twist.

SSH accomplishes X11 forwarding by forwardin a local X11 socket (normally a Unix Domain Socket) to a local TCP socket on the remote machine, then negotiating the display cookie, then setting the DISPLAY-Environment on the remote machine. This way all X11 traffic is encrypted over the ssh tunnel. The normal use case is to forward the local display to the remote machine (meaning allow remote applications to display x windows locally).

The advantage of using ssh is, that you don't need to put your X-Server into tcp listen mode (since the unix socket is used). And ssh handles the credential exchange.

  1. SSH to your laptop from your desktop computer (you don't need to use -X yet).
  2. In the remote shell enter export DISPLAY=:0 this makes the already running display on your notebook available to the shell you got via ssh. If you run any X command now, it will already appear on your notebook screen, but still run on your laptop (try it out to be safe).
  3. From this shell ssh back to your desktop computer, use -X this time. You now have a shell on the machine on which the ssh session originated but this time with working X. Run xeyes or xcalc to test it.
  4. echo $DISPLAY shows you the designation, your laptops X display has now on your desktop computer. I.e. :10 or :11.
  5. You can minimize the terminal now. Anytime you enter export DISPLAY=:10 (see what display number you got) on your desktop computer now, each program you run afterwards in the same shell will appear on you notebooks screen.

    This Variant is easy but slow, since all X11 traffic is forwarded via SSH.

Variant C - The original thinclient concept:

You can use your laptop to Open a desktop session running entirely on your desktop computer.

  1. Configure the display manager on your Desktop to answer to XDMCP Broadcasts. How to do this depends on your display manager. Some display managers don't support this at all, i.e. slim. XDM, KDM, WDM, GDM do support it.

  2. Start a X-Server on your Laptop, which requests the display manager from your desktop. Either a nested X: Xephyr :1 -query desktop or Xephyr :1 -broadcast Or by shutting down your Notebooks X-Server and enter on a System Terminal sudo Xorg :0 -broadcast

    The display manager will see to it, that credentials are generated and exchanged and everything. Congrats, you should now see a login window provided by your desktop computer.


You can use ssh X forwarding to achieve your goal. If you are in the same subnet than it is quit fast.

Install the ssh server and client on your laptop and desktop PC

sudo apt-get install ssh

To connect to the desktop PC, open a terminal on the laptop and type the following

ssh -X username@desktop_pc_ip

And you can start any software using the terminal, for example starting Firefox, just type firefox in the terminal.


Preparation

(you do this only once)

In your desktop install SSH server

sudo apt-get install openssh-server


From your laptop:

ssh -X username@desktop_pc_ip

In the terminal you get whatever you run will be on your desktop but displayed on your laptop. If you want to do the same while seated on your desktop (and send windows on your laptop) then go on.

On your terminal you run

echo $DISPLAY

This will show you something like:

localhost:10.0

From your desktop:

Open a terminal and run

DISPLAY=:10.0 firefox

This should send a firefox window on your laptop but running on your desktop. Make sure the number you put (e.g. 10.0) is the same as in the echo result