I'm using X11 forwarding over ssh to run Linux apps on my Windows box, and when the network drops it loses everything that was running. Is there anything similar to screen for X11?

  • Clarify. Why not just use screen? Or XVNC? You run screen on the Linux machine and when your network drops, reconnect and use screen -DR to reattach the session. – nix Apr 4 '11 at 19:34
  • @nix Will that work for X apps? – Michael Mrozek Apr 4 '11 at 19:44
  • 3
    @nix I don't think screen works for gui apps. – Abdullah Jibaly Apr 4 '11 at 19:51
  • Of course, screen would require running from an xterm. – nix Apr 4 '11 at 20:02

Xpra or the Xpra fork claim to be exactly that:

So basically it's screen for remote X apps.

I haven't used it in a while, but it worked pretty well when I tried it. You start the server on the remote machine:

[remote] $ xpra start :13

Then you attach to the server from your local machine:

[local] $ xpra attach ssh:remote:13

And now anything displayed on X display 13 on the remote machine will appear locally:

[remote] $ DISPLAY=:13 xeyes
| improve this answer | |

You're looking for VNC. The principle somewhat is similar to screen: you run a VNC server (the backgound SCREEN process), and a VNC client (the foreground screen process). The VNC server is an X server, so you can run X applications in it.

Run a VNC server on the Linux box and a client on the Windows box. You have several implementations to choose from; one possibility is TightVNC. TightVNC is in many Linux distributions (if it's not in yours, either install it or pick a different implementation), and there's a Windows client.

If your two machines aren't very close on the network — if there's a firewall or a risk of an eavesdropper between them — you'll need to tunnel the VNC traffic through ssh. Have ssh forward the local port 5900 to the remote port 5900 (5900 corresponds to the display :0, use 5901 for :1, etc.).

| improve this answer | |

Actually, you can forward X into screen. Only thing to do is to set up the $DISPLAY in the screen window so that it is the same out side of it.


after ssh -X into the remote machine, type

$ echo $DISPLAY

and copy the result, usually localhost:N.0. Then enter screen, in the local screen window,

$ export DISPLAY=localhost:N.0

After this, run any X required program within the screen window will do.

NOTE: for each screen window, the environment variables are independent. So for each window, you might need to set it up separately.


| improve this answer | |
  • 1
    Hi Chong, welcome to unix.SE. Since the details of the solution you link are simple, it's better to re-write them explicitly here. This way the answer is preserved should something happen to the post on askubuntu.com. Of course, it's a good idea to keep the link present as well because it helps to source your material. – drs Jun 19 '14 at 16:55
  • 2
    I tried this solution, but I cannot close my ssh session without killing the running X application. This somehow defeats the purpose of it... How should I disconnect from the remote host leaving the remote application running? – Tonin Jun 23 '14 at 12:13

I found X2Go to be very good at this. It creates separate windows like X11 does (Single application mode), and the latency is much better than xpra, which I found to be unusable.

| improve this answer | |

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.