Linux – Trying to get X11 over SSH working: Connection refused by server

cygwinlinuxsshx11forwarding

Using Cygwin/X11
Launch command in local Xterm for SSH:

xterm -e ssh -Y -v -l MyUser myserver.mydomain.com &

After logging in, I've run

setenv DISPLAY myclient.mydomain.com:0.0

When I try to launch an Xterm I get:

Xlib: connection to "myclient.mydomain.com:0.0" refused by server
Xlib: No protocol specified

xterm Xt error: Can't open display: myclient.mydomain.com:0.0

On another server I have no issues launching new xterm windows without running the setenv.
"echo $DISPLAY" on that server returns "localhost:11.0"

If I try using that on the other server I get the following:

$ setenv DISPLAY localhost:11.0
$ xterm
xterm Xt error: Can't open display: localhost:11.0

I figure I'm missing something pretty basic, but I'm not sure what it is.


EDIT:
Tried not setting the $DISPLAY:

Here's the results

$ echo $DISPLAY
DISPLAY: Undefined variable.
$ xlogo
Error: Can't open display:

Still not working 🙁


EDIT Again:
The above was on a straight login. I did not remove the $DISPLAY or change it before trying to run xlogo

Best Answer

Don't set the display on the remote side. By using the -Y parameter on SSH, it will set up a listener on the (remote)local side that gets tunneled back to the local side.

You should be able to do this:

local$ ssh -Y user@remote
remote$ xlogo

...and the xlogo will pop up.

Edit: this assumes that the display is set up on the local system first, ie:

local$ xlogo

...should work before you perform the ssh, as ssh just plugs the forward back to whatever the originating session thinks is the correct display. This is useful, since you can carry your display through multiple ssh sessions:

local$ ssh remote
remote$ ssh further
further$ xlogo

...should work.