X11 Forwarding can't open display (client rejected?)

ben picture ben · Jul 4, 2016 · Viewed 15.9k times · Source

I've read similar questions, and have applied the suggestions posted, but none seem to fix my issue...

In Putty, I've enabled x11 forwarding, with the 'X display location' set to 0.0

The remote Debian 8.4's X -version is 1.16.4, with the the /etc/ssh/ssh_config set to:

 ForwardX11 yes
 ForwardX11 Trusted yes

and /etc/ssh/sshd_config:

 X11Forwarding yes

I've also forced the DISPLAY variable to point to my local machine's IP:

 export DISPLAY=192.168.1.140:0.0

and verified it's set correctly (using 'echo $DISPLAY')

Finally, I restarted: 'service ssh restart' and 'service sshd restart'. Unfortunately, when I enter 'xterm&', I get the error "Can't open display: %s", and the locally running xming (Win8) never shows anything.

The Xming log seems to show an authentication error:

 winClipboardProc - Hello
 DetectUnicodeSupport - Windows Vista
 winClipboardProc - DISPLAY=127.0.0.1:0.0
 winMultiWindowXMsgProc - XOpenDisplay () returned and successfully opened the display.
 winInitMultiWindowWM - XOpenDisplay () returned and successfully opened the display.
 winClipboardProc - XOpenDisplay () returned and successfully opened the display.
 AUDIT: Mon Jul 04 09:40:48 2016: 2508 C:\Program Files (x86)\Xming\Xming.exe: client 4 rejected from IP 192.168.1.151 

 [Note: the 192.168.1.151 is the IP of the BBB (ifconfig -a)]

I also verified that the Window's firewall is NOT blocking xming.

Not sure if it's significant, but the remote debian is running on a beaglebone black.

Answer

JvO picture JvO · Jul 4, 2016

You shouldn't point the DISPLAY variable to your own machine. Rather, SSH will tunnel the connection from the remote machine through its connection to the local machine. When you login with Putty/SSH it will setup a DISPLAY variable:

$ echo $DISPLAY
localhost:10.0

xterm will connect to this 'local' display, which is really your xming server, securely forwarded through SSH connection.