设置 cygwin xserver 连接到 vagrant ubuntu 20

问题描述

我尝试使用 vagrant 在我的本地电脑上连接安装 ubuntu 并使用 XServer 进行本地 cygwin 安装 我尝试了不同的配置,但每次都得到:

vagrant@vagrant:~$ xclock
Error: Can't open display:

流浪者:ssh-config

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/HashiCorp/ubuntu-20.04/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes
  ForwardX11 yes

cygwin :

startxwin -- -listen tcp&

$ xauth:  file /home/foo/.Xauthority does not exist
xauth:  file /home/foo/.Xauthority does not exist

Welcome to the XWin X Server
Vendor: The Cygwin/X Project
Release: 1.20.10.0
OS: CYGWIN_NT-10.0-18363 foo-LP 3.1.7-340.x86_64 2020-08-22 17:48 UTC x86_64
OS: Windows 10  [Windows NT 10.0 build 18363] (Win64)
Package: version 1.20.10-1 built 2020-12-21

XWin was started with the following command line:

/usr/bin/XWin :0 -multiwindow -listen tcp -auth
 /home/foo/.serverauth.1395

(II) xorg.conf is not supported
(II) See http://x.cygwin.com/docs/faq/cygwin-x-faq.html for more information
LoadPreferences: /home/foo/.XWinrc not found
LoadPreferences: Loading /etc/X11/system.XWinrc
LoadPreferences: Done parsing the configuration file...
winDetectSupportedEngines - RemoteSession: no
winDetectSupportedEngines - DirectDraw4 installed,allowing ShadowDDNL
winDetectSupportedEngines - Returning,supported engines 00000005
winSetEngine - Multi Window or Rootless => ShadowGDI
winScreenInit - Using Windows display depth of 32 bits per pixel
winAllocateFBShadowGDI - Creating DIB with width: 1920 height: 1080 depth: 32
winFinishScreenInitFB - Masks: 00ff0000 0000ff00 000000ff
winInitVisualsShadowGDI - Masks 00ff0000 0000ff00 000000ff BPRGB 8 d 24 bpp 32
MIT-SHM extension disabled due to lack of kernel support
XFree86-Bigfont extension local-client optimization disabled due to lack of shared memory support in the kernel
glWinSelectGLimplementation: Loaded 'cygnativeGLthunk.dll'
(II) AIGLX: Testing pixelFormatIndex 1
GL_VERSION:     4.6.0 - Build 26.20.100.8141
GL_VENDOR:      Intel
GL_RENDERER:    Intel(R) UHD Graphics 620
(II) GLX: enabled GLX_SGI_make_current_read
(II) GLX: enabled GLX_SGI_swap_control
(II) GLX: enabled GLX_MESA_swap_control
(II) GLX: enabled GLX_SGIX_pbuffer
(II) GLX: enabled GLX_ARB_multisample
(II) GLX: enabled GLX_SGIS_multisample
(II) GLX: enabled GLX_ARB_fbconfig_float
(II) GLX: enabled GLX_EXT_fbconfig_packed_float
(II) GLX: enabled GLX_ARB_create_context
(II) GLX: enabled GLX_ARB_create_context_profile
(II) GLX: enabled GLX_ARB_create_context_robustness
(II) GLX: enabled GLX_EXT_create_context_es2_profile
(II) GLX: enabled GLX_ARB_framebuffer_sRGB
(II) AIGLX: enabled GLX_MESA_copy_sub_buffer
(II) 108 pixel formats reported by wglGetPixelFormatAttribivARB
(II) 72 fbConfigs
(II) ignored pixel formats: 0 not OpenGL,0 unknown pixel type,36 unaccelerated
(II) GLX: Initialized Win32 native WGL GL provider for screen 0
winPointerWarpCursor - Discarding first warp: 960 540
(--) 16 mouse buttons found
(--) Setting autorepeat to delay=500,rate=31
(--) Windows keyboard layout: "00000409" (00000409) "US",type 4
(--) Found matching XKB configuration "English (USA)"
(--) Model = "pc105" Layout = "us" Variant = "none" Options = "none"
Rules = "base" Model = "pc105" Layout = "us" Variant = "none" Options = "none"
winInitMultiWindowWM - DISPLAY=:0.0
winMultiWindowXMsgProc - DISPLAY=:0.0
winMultiWindowXMsgProc - xcb_connect() returned and successfully opened the display.
winProcEstablishConnection - winInitClipboard returned.
winClipboardThreadProc - DISPLAY=:0.0
winInitMultiWindowWM - xcb_connect () returned and successfully opened the display.
winClipboardProc - xcb_connect () returned and successfully opened the display.
Using Composite redirection

然后我按 ENTER 并执行:

export DISPLAY='localhost:0.0'

ssh -Y [email protected] -p 2222

ssh  -X -v [email protected] -p 2222 

我正在登录输入 xclock(已安装 x11 -apps)并获得:

vagrant@vagrant:~$ xclock
Error: Can't open display:

更新
它仍然无法正常工作,但我添加了更多我在网上看到的配置: 我使用 XWIN 服务器启动了 Cygwin,然后启动了 XTerm 窗口
设置在本地 Cygwin 术语上:

 export DISPLAY=:0.0

然后我的猫 ~/.ssh/config 看起来像:

Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/HashiCorp/ubuntu-20.04/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardX11 yes

在 Ubuntu 虚拟机中 /etc/ssh/ssh_config

Host *
#   ForwardAgent no
    ForwardX11 yes 
    ForwardX11Trusted yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected]
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes

$DISPLAY 未设置为任何内容且为空

然后这是来自 CYGWIN xterm 的 ssh 日志文件 ssh -v -X [email protected] -p 2222

OpenSSH_8.4p1,OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/meir.yanovich/.ssh/config
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file /home/foo/.ssh/id_rsa type 0
debug1: identity file /home/foo/.ssh/id_rsa-cert type -1
debug1: identity file /home/foo/.ssh/id_dsa type -1
debug1: identity file /home/foo/.ssh/id_dsa-cert type -1
debug1: identity file /home/foo/.ssh/id_ecdsa type -1
debug1: identity file /home/foo/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/foo/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/foo/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/foo/.ssh/id_ed25519 type -1
debug1: identity file /home/foo/.ssh/id_ed25519-cert type -1
debug1: identity file /home/foo/.ssh/id_ed25519_sk type -1
debug1: identity file /home/foo/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/foo/.ssh/id_xmss type -1
debug1: identity file /home/foo/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.4
debug1: Remote protocol version 2.0,remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 127.0.0.1:2222 as 'vagrant'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:FtCGiDnzzrbYlo8+1w8nPocBOm1fX92/5YUbRItfN60
debug1: Host '[127.0.0.1]:2222' is known and matches the ECDSA host key.
debug1: Found key in /home/foo/.ssh/known_hosts:372
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/foo/.ssh/id_rsa RSA SHA256:S7sIXRYo1a/T/5plCgiFtUtRi19gcAHo/iUb6aqbcOY agent
debug1: Will attempt key: /home/foo/.ssh/id_dsa 
debug1: Will attempt key: /home/foo/.ssh/id_ecdsa 
debug1: Will attempt key: /home/foo/.ssh/id_ecdsa_sk 
debug1: Will attempt key: /home/foo/.ssh/id_ed25519 
debug1: Will attempt key: /home/foo/.ssh/id_ed25519_sk 
debug1: Will attempt key: /home/foo/.ssh/id_xmss 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/foo/.ssh/id_rsa RSA SHA256:S7sIXRYo1a/T/5plCgiFtUtRi19gcAHo/iUb6aqbcOY agent
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/foo/.ssh/id_dsa
debug1: Trying private key: /home/foo/.ssh/id_ecdsa
debug1: Trying private key: /home/foo/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/foo/.ssh/id_ed25519
debug1: Trying private key: /home/foo/.ssh/id_ed25519_sk
debug1: Trying private key: /home/foo/.ssh/id_xmss

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)