ssh -X "Xt error: Can't open display: :0.0"
If ssh is able to establish the connection, it will set DISPLAY
to the proper value. Since you have X11DisplayOffset
set to 10 (the default value), ssh will use the first available display starting at 10. If you see a value that's lower than 10¹, then something is interfering with the normal X11 forwarding set up by ssh, at least by overriding DISPLAY
. The value :0
(or :0.0
, the part after the dot is irrelevant) indicates the first display that was started on the machine, which in typical cases is the active session (or the graphical login prompt) on the machine's console.
The most likely explanation for the behavior you observe is that one of your shell configuration files sets DISPLAY
. The most obvious culprit is ~/.bashrc
(which due to a quirk of bash is executed whenever the parent of bash is rshd
or sshd
, even if the shell is not interactive). Another file that defines environment variables is /etc/environment
. If that's the case, the solution is obvious: don't set DISPLAY
there. (There are very few cases where you need to set DISPLAY
manually.)
There are other exotic explanations. This might happen if you've changed your login shell to screen
(a cute idea in theory, but not practical) and you have a shell initialization file that forcibly sets DISPLAY
inside screen (not such a good idea). This could also happen if you configured the server to accept environment variables sent by the client (AcceptEnv
directive in sshd_config
), the client is sending DISPLAY
, and the X connection couldn't be established. Or it could happen if you set an environment variable on the server via the command
directive in ~/.ssh/authorized_keys
. Or xterm
could be a script.
¹ Or whatever the value of X11DisplayOffset
is in the server configuration, but it's hardly ever changed from the default.
Your command should work, or at least it does for me. Try this instead:
ssh -Y user@machine xterm
Edit (1):
Try this:
ssh -X user@machine env
That should show all the environment. There should be various SSH things in there, and also DISPLAY. DISPLAY should be 10.0.
You could also try this:
ssh -X user@machine DISPLAY=10.0 xterm
As well as X11Forwarding yes
, I also needed to add
X11UseLocalhost no
in /etc/ssh/sshd_config
as described here.
Access control of X is probably in the way.
Run xhost +
(from package x11-xserver-utils
) to completely disable access control.
I found that xauth had not been installed.