-
Notifications
You must be signed in to change notification settings - Fork 794
Description
Background/Setup
SupportX11 Forwarding (#1515) was recently and delivered as part of OpenSSH 8.1.0.0. However, the appear to be some problems with this functionality. Here is how I set up for my test.
- Install OpenSSH 8.1.0.0.
- Install VcXsrv 1.20.6.0.
- Add configuration to C:\ProgramData\ssh\ssh_config:
XAuthLocation "/C:/Program Files/VcXsrv/xauth.exe"
- Update environment variable:
set PATH=%PATH%;C:\Program Files\OpenSSH;C:\Program Files\VcXSrv
. - Update environment variable:
set DISPLAY=localhost:0.0
. - Verify VcXsrv installation by running
vcxsrv.exe :0 -multiwindow
and then localxclock.exe
.
Problems
I encountered two issues when exercising this functionality.
ForwardX11Trusted Does Not Work
I tried three mechanisms to enabled trusted X11 forwarding:
- Supplying the configuration option on the command line (e.g.,
ssh.exe -vvv -o "ForwardX11Trusted yes" user@host
). The debug output contains no references to X11 forwarding, and the DISPLAY environment variable is not set in the resulting session. - Supplying the configuration option in the config file (C:\ProgramData\ssh\ssh_config). The debug output contains no references to X11 forwarding, and the DISPLAY environment variable is not set in the resulting session.
- Using the
-Y
command line option. This does work, subject to mishandling of Xauth described below.
Mishandling of Xauth and DISPLAY Environment Variable
When running ssh.exe -vvv -Y user@host
, the following the following is seen in the debug output:
debug2: x11_get_proto: /C:/Program Files/VcXsrv/xauth.exe list unix:0.0 2>NUL
Warning: No xauth data; using fake authentication data for X11 forwarding.
debug1: Requesting X11 forwarding with authentication spoofing.
Apparently, ssh is trying to convert localhost
in the DISPLAY environment variable to unix
, as implemented in client_x11_get_proto()
(clientloop.c):
if (xauth_path != NULL) {
/*
* Handle FamilyLocal case where $DISPLAY does
* not match an authorization entry. For this we
* just try "xauth list unix:displaynum.screennum".
* XXX: "localhost" match to determine FamilyLocal
* is not perfect.
*/
if (strncmp(display, "localhost:", 10) == 0) {
if ((r = snprintf(xdisplay, sizeof(xdisplay), "unix:%s",
display + 10)) < 0 ||
(size_t)r >= sizeof(xdisplay)) {
error("%s: display name too long", __func__);
return -1;
}
display = xdisplay;
}
This does not make much sense, since, unlike on Linux, VcXsrv apparently does not accept DISPLAY to be set to :0.0
or unix:0.0
; even the bundled xclock.exe will not run with DISPLAY set to this. Running xauth independently without redirecting stderr further makes this point:
C:\Users\username>xauth list unix:0.0
xauth: (argv):1: bad display name "unix:0.0" in "list" command
I tried to thwart this logic by setting DISPLAY differently:
set DISPLAY=127.0.0.1:0.0
When running ssh.exe again (as before) I now get:
debug2: x11_get_proto: /C:/Program Files/VcXsrv/xauth.exe list 127.0.0.1:0.0 2>NUL
Warning: No xauth data; using fake authentication data for X11 forwarding.
debug1: Requesting X11 forwarding with authentication spoofing.
So, while the xauth command now looks reasonable, the result does not. I even tried creating my own authorization entry for the display:
C:\Users\username>xauth
xauth> generate 127.0.0.1:0.0 . trusted
authorization id is 121
xauth> exit
Writing authority file \users\username\.Xauthority
Then I verified that xauth would send info to stdout about it:
C:\Users\username>xauth list 127.0.0.1:0.0 2>NUL
hostname/unix:0 MIT-MAGIC-COOKIE-1 69f77dc9eba6e054cffc6f1b48ca853b
But I still received the same debug messages. Looking at the code I found:
if (trusted || generated) {
xasprintf(&cmd,
"%s %s%s list %s 2>" _PATH_DEVNULL,
xauth_path,
generated ? "-f " : "" ,
generated ? xauthfile : "",
display);
debug2("x11_get_proto: %s", cmd);
f = popen(cmd, "r");
if (f && fgets(line, sizeof(line), f) &&
sscanf(line, "%*s %511s %511s", proto, data) == 2)
got_data = 1;
if (f)
pclose(f);
free(cmd);
}
// ...
if (!got_data) {
u_int8_t rnd[16];
u_int i;
logit("Warning: No xauth data; "
"using fake authentication data for X11 forwarding.");
As evidenced by the warning, one or more of the following must be happening since got_data
is clearly not being set to 1:
- File handle
f
is bad. - xauth.exe is not being run or is not producing output for capture into
line
byfgets()
. sscanf()
is not properly parsingline
.
Unfortunately, based on the existing debug statements, it is hard to determine more closely what is happening.
In the end, VcXsrv's default behavior is to allow connections from localhost so the fake authentication data ends up working. However, it would be nice for this to work as intended, even if for no other reason than to get rid of the warning.