Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a laptop and a server. On the same lan network, I can ssh with X11 forwarding to the server via:

ssh -Y -C [email protected]

When I execute anything that opens an x11 window, things work. For example, xterm and chromium-browser.

On my router, I have port 22 forwarded to my server. Thus, when I am outside my network, I can successfully ssh into my server via

ssh [email protected]

The problem is when I want X11 fowarding. When I add in the flags "-Y -C", I can still log in. However, windows are not forwarded as I get errors such as these: - (chromium-browser:21079): Gtk-WARNING **: cannot open display: - xterm Xt error: Can't open display: xterm: DISPLAY is not set

I swear this used to work but for some reason, it doesn't now. The only change I can think of recently was updating software on the server (10.04 to 10.04 with updates). Also, on my laptop, I recently updated to ubuntu 11.04.

I think it has to be a recent issue as I would have caught this long before. Also, I don't recall this error every occuring before when I opened x11 windows. I think it has to do with my laptop, as when I try similar things on other servers (outside network, at school), x11 windows also doesn't open (and they have before).

I've googled but could not fine anything relevant. X11 forwarding must be on as it works internally. Externally, it doesn't. Please let me know your suggestions for debugging or fixing.

share|improve this question
add comment

2 Answers

You haven't specified the actual flag to enable X11 forwarding, which is -X. (-Y only switches it to "trusted" mode.)

My guess is that you have X11 forwarding enabled in ~/.ssh/config or /etc/ssh/ssh_config in a few machines, which is why it worked from there without -X specified.

share|improve this answer
    
Actually, "-Y" does enable x11 forwarding. I thought "-Y" is preferred over "-X"? Anyhow, I tried it with -X itself and I have the same results. –  Vinh Nguyen May 12 '11 at 5:14
    
@Vinh: Try connecting with -X -v -v, see if you have anything interesting in the log. –  grawity May 12 '11 at 5:18
add comment

@grawity (sorry too long for the comments)

$ ssh -X -v -v -v [email protected]
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /home/username/.ssh/config
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_request_forwards: requesting forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 2616
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 3
$ xterm
xterm Xt error: Can't open display: 
xterm:  DISPLAY is not set

$ exit
logout
debug1: mux_client_request_session: master session id: 3
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
Shared connection to external.ip closed.

I JUST REALIZED SOMETHING. I use SSHFS with some of these servers I'm trying (mounting some directories). I also have the following in ~/.ssh/config:

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

to keep a single session alive (and keep using it). Maybe X11 Forwarding isn't set up in my initial session from SSHFS.

share|improve this answer
    
I've narrowed down the problem. It is because I use sshfs to mount directories onto my laptop, and at the same time, I have "ControlMaster auto" in my ~/.ssh/config to keep a single session alive and to re-use it. This single session does not have X11 forwarding enabled. Not sure how to fix this yet but I've emailed the sshfs list. Consider this ticket closed. Thanks. –  Vinh Nguyen May 12 '11 at 17:39
    
My solution to this all can be found here –  Vinh Nguyen May 12 '11 at 19:33
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.