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 use Cygwin/X to ssh into a VirtualBox hosted Ubuntu Server which has had the various X bits and pieces installed:

ssh -X user@IPADDRESS

Once in, I can run gnome-terminal and the terminal pops up. Once in there I can open new tabs, run geany (a text editor like GEdit) and so-on, and it all works, the windows open and everything is fine.

Then, at some point, something happens and I am unable to open any new applications that make use of X. Existing applications function fine, but anything new will complain that it can't open the display. eg:

user@SERVER:/mnt/smb$ geany
Geany: cannot open display

I think this starts happening after I have used sudo to execute a command such as:

sudo apt-get install XXXX

After the problem starts, the DISPLAY environment variable is the same as it was before.

The only other piece of information that may be of use is that when I first log in to the machine, the following appears immediately after authentication:

Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.

Any ideas?

share|improve this question

2 Answers 2

up vote 0 down vote accepted
+50

Some ideas:

  1. Try to invoke ssh as ssh -Y, which is to say that you trust the machine you are ssh-ing to. This might have as effect only the removal of the first warning, but is worth a try.
  2. Ensure that no communication is blocked by a firewall
  3. Ensure that the remote server doesn't have the XC-SECURITY extension enabled (SECURITY shows up in the output of xdpyinfo).
  4. Use ssh -vvv for more info.
share|improve this answer
    
By installing x11tools in order to have access to xdpyinfo, this problem seems to have gone away :) If you have any input as to why, I would be very interested. –  Rich Mar 1 '11 at 15:47
    
Thanks for the bounty, even if this was a really left-handed fix. I would guess that the reason it works was a non-declared dependency. –  harrymc Mar 1 '11 at 18:07

sudo wipes your DISPLAY.

The sudo documentation recommends using "pam_env" in the middle of a session to restore the login environment -- trouble is, it can't. Only on initial login are things like REMOTE_HOST and DISPLAY available to pam_env so it can incorporate the correct values into your environment. Later on, calling pam_env again will just ensure those values are ZEROed, (even if configured your sudoers file NOT to re-init the environment). I.e. because of the bad security information given out in the sudo docs, DISPLAY is likely to be cleared no matter what.

To fix it, you have to undo the misconfiguration setup by your distro (who followed the sudo advice), as well as configure sudo not to trash your env. Even still. If there are functions you relied on in your environment (I have one to determine if I am on cygwin or not -- use the same init shells on both) -- they are wiped. So any security and config information kept in functions because that is more convenient or useful will be wiped by sudo.

In short. sudo needs to be fixed or replaced.

Too bad bounties are forced to be closed out before correct answers come along. But better to have correct answers here than not.

share|improve this answer

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.