User:Armin/SSH X11 Forward via NX
X11 forwarding of graphical interfaces of remotely executed programs via SSH is a convenient feature. However, due to the X11 protocol, this is not very efficient over slow and non-local network connections, in particular when gateways/proxies are involved. X2Go offers an easy to use alternative approach, but may not be desirable in all use cases.
On the local machine, ssh to <host> shell via <gateway>, opening a shell and at the same time create a port forward of local port 20000 to remote 4008 on <host>:
$ ssh -tt -L20000:<host>:4008 <gateway> ssh <host>
Note: this assumes that the forwarded port to <host> is accessible by <gateway>.
On <host>, start nxproxy with options to your liking and send it to background by issuing:
$ nxproxy -C :8 link=adsl render=y encryption=1 &
nxproxy will now create a display at :8 and listen on <host> port 4008
On the local machine, connect the nxproxy to the remote display to the local display for rendering:
$ DISPLAY=:0 nxproxy -S localhost:16000 &
At this point, basic X11 programs such as xterm would forward to the local machine. You can test this by by issuing:
$ DISPLAY=:8 xterm
on <host>. However, programs based on GTK+ or other toolkits might use features of X11, that would prevent them from working in this configuration.
To fix this, start nxagent in rootless mode on <host> to create another display (:9) which is forwarded to the local machine via the nxproxy connection on :8
$ nxagent -R -display nx/:8 :9 &
For convenience, export DISPLAY on <host>:
$ export DISPLAY=:9
and you may start using programs such as gvim, gedit or firefox just as if you had connected via ssh -X.