Передача X11 посредством соединения WSL

У меня есть следующая установка:

Мой рабочий компьютер запускает Ubuntu 18.04 со следующим /etc/ssh/sshd_config:

#       $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Port 3022
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

PubkeyAuthentication yes

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile     .ssh/authorized_keys .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
#PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM no

AllowAgentForwarding no
AllowTcpForwarding no
#GatewayPorts no
X11Forwarding yes
X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintLastLog yes
TCPKeepAlive no
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
Banner /etc/issue.net
PrintMotd yes

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

# override default of no subsystems
Subsystem       sftp    /usr/lib/openssh/sftp-server

# Example of overriding settings on a per-user basis
Match User me
        AllowAgentForwarding yes
        AllowTcpForwarding yes
        X11Forwarding yes
        X11UseLocalhost no
        PermitTunnel yes

У меня в настоящее время нет физического доступа к рабочему компьютеру. Таким образом, я соединяюсь с ним из дома. Мой домашний ПК запускает Windows 10 с Windows Subshell для Linux под управлением Ubuntu 18.04. Там ~/.ssh/config содержит следующее:

# Defaults
Host *
        ForwardAgent no
        ForwardX11 no
        ForwardX11Trusted no
        User me
        Protocol 2
        ServerAliveInterval 0
        TcpKeepAlive no

# Workstation
Host workcomputer
        HostName machine.domain.com
        Port 3022
        ForwardX11 Yes
        ForwardX11Trusted Yes

и ~/.profile содержит строку

DISPLAY=:0

Домашнему компьютеру также установили VcXsrv и выполнение.

Я могу запустить приложения как xeyes локально и они открываются очень хорошо в окне VcXsrv (хотя я должен выполнить его как xeyes -display :0 потому что xeyes кажется, не использует переменную $DISPLAY). Однако я не могу заставить удаленные приложения GUI появляться.

me@Home:~$ ssh workcomputer
me@Work:~$ echo $DISPLAY

me@Work:~$ gedit
Unable to init server: Could not connect: Connection refused

(gedit:20107): Gtk-WARNING **: 16:58:42.096: cannot open display:

Я попытался работать export DISPLAY=:0 на удаленной машине и gedit работал после этого, но не появился на моей локальной машине в окне VcXsrv. Я также попробовал export DISPLAY=:10 но это снова привело к Connection refused. Я также пытался соединиться с ssh -X но это не работало также.

Что еще я могу попытаться смочь открыть удаленные приложения GUI на своем локальном X-сервере?

2
задан 18 March 2020 в 14:54

1 ответ

Таким образом, мне наконец удалось сделать эту работу правильно. Несколько вещей сделать (в дополнение к исходному сообщению):

  1. И на локальной и на удаленной установке xauth и генерируют записи для :0.

    sudo apt install xauth
    xauth generate :0 . trusted
    

    Это может или не может требоваться на удаленном, но это определенно требуется на локальном избавиться от предупреждений о недостающих данных аутентификации. Это может также требоваться на локальном в зависимости от того, где Ваш xauth установлен.

  2. На локальном помещает эту точную строку (не сокращаясь или опуская что-либо) в ~/.bashrc (удалите его из ~/.profile):

    export DISPLAY=localhost:0.0
    
  3. Даже при том, что ForwardX11 и ForwardX11Trusted установлены на Yes в Вашем ~/.ssh/config, используйте -Y (или -X если Вы не доверяете соединению), переключаются при соединении:

    ssh -Y workcomputer
    

    Я не уверен, почему это требуется, но по некоторым причинам это не передает X11 без переключателей для меня.

1
ответ дан 7 April 2020 в 23:34

Другие вопросы по тегам:

Похожие вопросы: