Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

http://superuser.com/questions/190801/linux-wmctrl-cannot-open-display-when-session-initiated-via-sshscreen/190878#190878

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
I think you pointed me in the right direction, but I can't get it to work. I am fine with using vnc, x11vnc or the ssvnc I just heard about. Any solution is fine as long as it works. My ssh tunnel is set up and I cannot change ports. –  MountainX Jul 8 '13 at 22:55
    
I'm not really sure what do you mean by changing ports. The idea is that x11vnc connects to a running X server end exports the display (by default on port 5900, but this can be overridden). You forward this port through ssh. This can be done in the ssh command with the -L option or in a live connection - see the ESCAPE CHARACTERS section of man ssh. –  peterph Jul 9 '13 at 14:38
    
I will update my question based on what I have learned and what I have tried. See if my update makes it more clear where my problem is. Thanks –  MountainX Jul 9 '13 at 19:29
    
I edited it so extensively that it ended up being a new question. So I decided it would be better to post it as a new question. I hope that is acceptable. BTW, I will accept the best answers at this question and the new one. –  MountainX Jul 9 '13 at 19:59
    
Thanks for your help! –  MountainX Jul 10 '13 at 6:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.