通過 SSH 隧道的 VNC 是否工作,原因未知

通過 SSH 隧道的 VNC 是否工作,原因未知

我有 Ubuntu 20.04.3,在兩台電腦 PC1 和 PC2 上。我可以透過 VNC (remmina) 在兩者之間進行連接,沒有任何問題。

現在我嘗試透過 SSH 隧道使用 VNC。

  1. 設定隧道

     [PC1]$ ssh -L 5900:localhost:5900 [email protected]
     bind [127.0.0.1]:5900: Address already in use
     channel_setup_fwd_listener_tcpip: cannot listen to port: 5900
     Could not request local forwarding.
     Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-41-generic x86_64)
     ...
    
  2. 在 remmina 中,使用 Protocol Remmina VNC Plugin(與非隧道連接相同)連接到localhost:5900.系統要求我輸入在中設定的密碼設定->分享->螢幕分享。我輸入該密碼,然後我得到無法驗證,正在嘗試重新連線...

嘗試 PC2 -> PC1(透過 SSH 隧道)時也會發生相同的情況。

A。我怎樣才能解決這個問題?


我有另一台 PC3,裝有 Win10,我想使用 TigerVNC 從 PC3 到 PC1/2 進行 VNC。我也可以毫無問題地做到這一點。

現在我嘗試透過 SSH 隧道使用 VNC。我可以在 PC3 中使用 mingw64 提示字元執行 PC3 -> PC1

  1. 在 mingw64 bash 提示字元中,

    [PC3]$ ssh -L 5900:localhost:5900 [email protected]
    bind [127.0.0.1]:5900: Address already in use
    channel_setup_fwd_listener_tcpip: cannot listen to port: 5900
    Could not request local forwarding.
    Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-41-generic x86_64)
    ...
    
  2. 在 TigerVNC 中,連接到localhost:5900.系統要求我輸入在中設定的密碼設定->分享->螢幕分享。輸入該密碼後,PC3 中已出現 VNC 畫面。

如果我嘗試對 PC3 -> PC2 執行相同的操作,我會得到

  1. 在 mingw64 bash 提示字元中,

    [PC3]$ ssh -L 5900:localhost:5900 [email protected]
    bind [127.0.0.1]:5900: Address already in use
    channel_setup_fwd_listener_tcpip: cannot listen to port: 5900
    Could not request local forwarding.
    Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-41-generic x86_64)
    ...
    
  2. 在 TigerVNC 中,連接到localhost:5900.系統要求我輸入在中設定的密碼設定->分享->螢幕分享。我輸入該密碼,然後我得到驗證失敗

B.我怎樣才能解決這個問題?


以下資訊可能有用:在 PC1 中我有

$ gsettings list-recursively org.gnome.Vino
org.gnome.Vino prompt-enabled false
org.gnome.Vino require-encryption false
org.gnome.Vino use-alternative-port false
org.gnome.Vino disable-background false
org.gnome.Vino disable-xdamage false
org.gnome.Vino alternative-port uint16 5900
org.gnome.Vino icon-visibility 'client'
org.gnome.Vino authentication-methods ['vnc']
org.gnome.Vino network-interface ''
org.gnome.Vino notify-on-connect true
org.gnome.Vino mailto ''
org.gnome.Vino lock-screen-on-disconnect false
org.gnome.Vino use-upnp false
org.gnome.Vino vnc-password '<12-char string>'
org.gnome.Vino view-only false

在 PC2 中我也有相同的,除了

org.gnome.Vino vnc-password 'keyring'

當我嘗試設定密碼時設定->分享->螢幕分享,我被限制為8個字符,這不是我遇到的通常情況。

答案1

我修復了PC1和PC2之間的差異,這導致

PC3 -> PC1 (SSH tunnel): OK
PC3 -> PC2 (SSH tunnel): Failed

/etc/ssh/sshd_configPC2中,出於安全原因我之前已經設定過AllowTcpForwarding no。評論該行,我可以連接。


然後我修復了 SSH 隧道 PC1 -> PC2

  1. 設定隧道

     [PC1]$ ssh -L 5900:localhost:5900 [email protected]
     Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-41-generic x86_64)
     ...
    
  2. 在 remmina 中,使用 Protocol Remmina VNC Plugin(與非隧道連線相同)連線到 localhost:5902。系統要求我輸入在中設定的密碼設定->分享->螢幕分享。我輸入該密碼,然後就得到了遠端桌面。

PC2 -> PC1 相同。

相關內容