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?

- 35,991

- 615
4 Answers
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

- 21,373

- 93,103
- 40
- 240
- 233
-
5There's also WinSwitch, which at a glance looks like it integrates xpra and other related software. – Gilles 'SO- stop being evil' Apr 04 '11 at 19:55
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.).

- 67,283
- 35
- 116
- 255

- 829,060
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.
Procedure
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.
References
-
1Hi 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
-
4I 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? – Lætitia Jun 23 '14 at 12:13
screen
? OrXVNC
? You run screen on the Linux machine and when your network drops, reconnect and usescreen -DR
to reattach the session. – nix Apr 04 '11 at 19:34screen
works for gui apps. – Abdullah Jibaly Apr 04 '11 at 19:51