I have a reverse ssh tunnel through a middleman server set up and working. I'm running Kubuntu 12.04 here and on the remote machine. I want to open a remote desktop session. Until now I've been using Team Viewer to log in to the remote desktop. I'd like to achieve similar results without Team Viewer. I understand X over SSH will achieve this. If I need vnc, that's fine too.Here's my issue at the moment. When I am connected to the remote machine via the tunnel I get this error:$ startkde &$ $DISPLAY is not set or cannot connect to the X server.I'm connecting with the -Y SSH option and using keys (not passwords). Everything related to SSH seems to be working fine. The only problem I see is with X. Here's another example:$ xeyes &$ Error: Can't open display: And$ echo $DISPLAY$ (returns nothing)These answers seem relevant but I haven't been able to understand them in enough detail to work out a solution in my case:Can I launch a graphical program on another user's desktop as root?https://superuser.com/questions/190801/linux-wmctrl-cannot-open-display-when-session-initiated-via-sshscreen/190878#190878
Remote desktop (KDE) over SSH reverse tunnel
ssh;x11;kde;ssh tunneling;remote desktop
If you are using a server-in-the-middle to interconnect two systems, chances are at least one of the lines is rather slow. In that case VNC is likely to give you better performance, since you can tune the bandwidth/performance requiremens/quality ratios better (this is actually valid for most setups, unless you are on a reliable 100Mbit+ network).I personally like x11vnc, which connects to a running X server and forwards the inputs/output over the VNC protocol (this can be done as soon the X server is running, so you can interact even with a display manager). The X server in question can be both a regular one (which outputs to a real display) or a framebuffer based one like Xvfb. You can then use any VNC client to connect to the exported X server. And of course you probably want to tunnel the transmissionn through ssh or stunnel. The man page of x11vnc is quite exhaustive and even has a frequently used command line example at the beginning.Ths also allows you to remotely connect to a running session to help somebody solve a problem remotely. As an important bonus, since just the inputs and output are forwarded rather than the X protocol itself, network disconnects will just interrupt the session, but all of the programs remain running, which is not the case of X through SSH.If for some reason you really want to tunnel X11 through SSH, you must ensure that the DISPLAY environment variable is set up properly by ssh. Without it you can't proceed, because the applications won't know which server to connect to. Check whether the X11Forwarding directive is set to yes in your sshd configuration.Last but not the least, you probably don't want to run startkde4 (or any other X session for that matter) over SSH - the network load will likely be quite heavy - VNC will serve you better again.