Don't forget to verify that the sshd config files (usually /etc/ssh/sshd_config) have X11Forwarding set to yes as well.
–
Matrix MoleOct 22 '12 at 6:25

Here's my use case: I'm on my desktop and i open Firefox, for example, but i want the browser window to open on my laptop display and still run on my desktop. I'm looking for a functionality similar to workspaces, but instead of a local workspace (4 screens on the same pc) to use a remote workspace (the laptop)
–
Vlad BalmosOct 22 '12 at 8:59

1

Also you can try the x2x package, you can use one keyboard and mouse in different machine. ex: ssh -X user@host x2x -west -to :0
–
runOct 22 '12 at 12:35

Be aware that by opening up access to your desktop's X server, you're giving quite wide ranging access to the remote machine. If your server was compromised, this could be used to get into your desktop as well. X11 forwarding is useful, but think about what you are doing, and don't turn it on by default.
–
mc0eNov 21 '14 at 14:51

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 ist 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).

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.

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.

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).

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.

echo $DISPLAY shows you the designation, your laptops X display has now on your desktop computer. I.e. :10 or :11.

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.

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.

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.

BTW. All this wonderful X11-Functionality will just stop working once Ubuntu switches to Wayland. NAtive wayland applications cannot even be forwarded via ssh anymore.
–
Paul HänschOct 27 '12 at 14:57

1

Isn't it quite ironical that there is no graphical toolchain to control your X-Server? If you truly want to work with GUIs you have to dominate the command line first.
–
Paul HänschOct 27 '12 at 14:59

General Hint: The first program you may want to start on your remote display is an application starter. I.e. lxpanel or something. This savel a lot of command line work.
–
Paul HänschOct 27 '12 at 21:07

Virtualgl will create an extra(background) desktop (TightVNC Style) that you can access via a turbo VNC client. It will function as a remote desktop type deal -> But it will play smooth video over a network.

If you looking for a way to offload CPU overhead for a remote connection, so you can run apps from your computer on your laptop, then that would be what I would do.

Yeah, "TurboVNC" (moreso its component VirtualGL) IS the result of my searching for a remote desktop program that would let me play Video Games and Movies. It would function easily as an extra monitor.
–
TardisGuyOct 25 '12 at 8:45

thanks, i'll try that and see how it works! i
–
Vlad BalmosOct 23 '12 at 20:31

tried that. opened up screen from terminal, started firefox on the desktop, then sshed from the laptop into the desktop, attached the screen session, but i don't get any window on the laptop, just the output from the running program in screen.
–
Vlad BalmosOct 23 '12 at 20:38

You were mixing it up. Wait... at least one of you did. Install screen on your desktop computer, use your notebook to ssh -X to your desktop, start screen in the ssh session, detach it and leave the session running. Then reattach the screen session with hands on your desktop computer and run something. This is similiar to my "SSH with a twist" answer. Using screen makes it a bit more conveniant.
–
Paul HänschOct 27 '12 at 21:11

Xdmx is proxy X server that provides multi-head support for multiple displays attached to different machines (each of which is running a typical X server). When Xinerama is used with Xdmx, the multiple displays on multiple machines are presented to the user as a single unified screen.