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.

On my local machine, I run:

ssh -X me@remotemachine.com

(For completeness, I have also tested all of the following using -Y with identical results).

As expected, this accesses remotemachine.com fine, and all appears well. If I then attempt to run xcalc however, I get:

 connect /tmp/.X11-unix/X0: No such file or directory
 Error: Can't open display: localhost:10.0

But,

$ ls -la /tmp/.X11-unix/
total 36
drwxrwxrwt 2 root root  4096 2012-11-23 09:29 .
drwxrwxrwt 8 root root 32768 2012-11-29 08:22 ..
srwxrwxrwx 1 root root     0 2012-11-23 09:29 X0

So not only does /tmp/.X11-unix/X0 exist, it has universal r/w/x permissions!

I've previously used x-forwarding without issue, though not in some time...

uname -a on the server for reference:

Linux machinename 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16 19:52:42 UTC 2010 x86_64 GNU/Linux

Been searching around on the web for a couple hours now without success. Other mentions of the same problem, but no solutions.

share|improve this question
    
Note that it's the file on the local machine that you need to check here, not the remote one. I would use strace -fo /tmp/trace ssh.... to check that it does try to connect that Unix domain socket. –  Stephane Chazelas Nov 29 '12 at 14:27
    
Ah! That could be it. Strangely, my local machine does not have a /tmp/.X11-unix/ directory though. –  John Doucette Nov 29 '12 at 14:46
add comment

1 Answer

up vote 5 down vote accepted

If you have a X server running and the DISPLAY environment variable is set to :0, that tells applications to connect to the X server using a unix domain socket which is generally to be found on Linux in /tmp/.X11-unix/X0 (though see below about the abstract namespace on recent Linux).

When you ssh to machine remotemachine, sshd on remotemachine sets DISPLAY to localhost:10 (for instance), which this time means that X connections are do be done over TCP to port 6010 of machine localhost. sshd on remotemachine listens for connections on there and forwards any incoming connection to the ssh client. The ssh client then tries to connect to /tmp/.X11-unix/X0 to contact your X server.

Now, maybe you don't have a X server running (are you on Mac?) or maybe the unix domain socket is not to be found in /tmp/.X11-unix which would mean ssh hasn't been configured properly at compile time.

To figure out what the proper path is for the unix socket, you could try a strace -e connect xlogo (or the equivalent on your system) on your local machine to see what a normal X application does.

netstat -x | grep X may also give a clue.

For the record, on a Linux Debian wheezy machine here, Xorg listens on both /tmp/.X11-unix/X0 in the filesystem and /tmp/.X11-unix/X0 on the abstract namespace (generally written @/tmp/.X11-unix/X0). From strace, X11 applications seem to now use that abstract namespace by default, which explains why those still work if /tmp/.X11-unix is removed, while ssh doesn't use that abstract namespace.

share|improve this answer
1  
Or check lsof -p <PID of your local X server> where you should be able to find the /some/thing/Xn file, the n being your DISPLAY number. –  peterph Nov 29 '12 at 14:58
    
Thanks, this was quite helpful. Somehow my /tmp/.X11-unix/X0 file was removed, although there was still an X server running. A quick reboot seems to have resolved the problem. Possibly caused by some updates I did a while back. –  John Doucette Nov 29 '12 at 15:00
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.