# More efficient X-forwarding?

I open GUI remote programs by SSHing with the -X (or -Y) flag, e.g.,

$ssh -Y user@host.com  Recently, I found there is a much more efficient way to do this with web browsing only: $ ssh -DNNNN user@host.com


where NNNN is a four digit port number. Then I configure my local browser to connect through a proxy via port NNNN. This is much more efficient than the first SSH method because all the GUI information does not need to be transported through the tunnel, only the web data I am requesting.

My question is: is there a more efficient way to SSH with X-forwarding in general? Maybe some scheme that utilizes local libraries or rendering or something to aid in operating a GUI program hosted remotely?

• You might want to try experimenting with VNC, see unix.stackexchange.com/questions/1960/… – steve May 31 '16 at 14:49
• X window system protocol is not an efficient thing. As the other comment suggests try VNC – Serge May 31 '16 at 15:08
• Other random suggestion: FreeNX / X2go – derobert May 31 '16 at 15:52
• You're comparing apples to oranges. The SOCKS proxy trick works if all you want to do view websites via the SSH server; it's markedly less useful if you want to run, say, gparted. – Shadur Mar 28 '17 at 7:49

You are mixing up terms. The first thing is X11 forwarding and it is inefficient by definition and you can't do almost anything about that (it is not made for high-latency connections and decades ago]. In comparison to the other method, it is inefficient, because it is transferring whole gui (of broswer?) over the newtwork.

The other is SOCKS proxy (completely different thing) and it transfers only the network data you are interested in (encapsulated in the SOCKS protocol and SSH), which is obviously more efficient.

Your question is asked in the way that it is not possible to answer. What are you trying to achieve? Run GUI programs? Proxy network connections? Something totally different?

• I was trying to run an arbitrary program, such as a PDF viewer, Minesweeper, a custom made program using the Qt toolkit or maybe just a file manager window. I intentionally did not specify because I don't want people trying to solve that problem, but rather the issue of how to generally open GUI programs on a remote computer more efficiently than ssh -Y. – user1717828 Mar 28 '17 at 15:47

Try Xpra. It is the best X11 forwarding app, and more secure. It supports many codecs and compression formats, even x264. I used it to run skype on remote side, when I forced to do this by business, and wanted to keep my machine with open source code only. App is running persistent, so you can reconnect to it if you loose connection, just like GNU screen does.

Also take a look to X2GO, the open source NX implementation, being actively developed.

• In what sense is it "more secure"? – Kusalananda Mar 27 '17 at 16:26
• In basic X11 forwarding remote app can capture all keyboard events, even if you don't type in that app. I found that when I was forced to run skype, and installed it on remote side with X11 forwarding. I saw some discussion about that on forums. Xpra resolve this. – Ural Mar 28 '17 at 7:05
• I'd be interesting in reading about that. – Kusalananda Mar 28 '17 at 8:46

X forwarding is often slow, even on a relatively fast network. It suffers from both bandwidth and latency: many applications often wait for an answer from the server, and that can translate into noticeable delays.

You can improve the bandwidth by compressing. SSH can do compression with the -C option. You can also use dxpc, which is a special-purpose compression program that understands the X protocol and so can perform better than generalist compression. However that won't help if the limiting factor is latency. Typically dxpc makes a lot of difference with lightweight applications on slow links, but doesn't improve much with heavyweight applications on fast links.

NX is a more advanced alternative to dxpc. Unlike dxpc, it doesn't just compress, it also caches some data, so it can counter latency.

One thing that can make a lot of difference is the use of server-rendered fonts (classic X11 text rendering) instead of client-rendered (fontconfig). They're a lot faster over a remote link. But server-rendered fonts have their downsides: they're uglier (no antialiasing), they're managed by the server rather than the application (not intrinsically a downside, but many applications want total control over their fonts), and many modern applications simply don't support them anymore.