X11 轉發在一段時間後停止工作

X11 轉發在一段時間後停止工作

我使用 Cygwin 透過 SSH 連接 linux 盒子(ubuntu 伺服器 12.04),並使用 X11 轉發。每次我 ssh 時,我都可以使用 X 轉發一段時間,然後它就停止工作(例如,gvim 說無法打開顯示)。如果我退出並重新 ssh,它會再次開始工作。並在一段時間後再次停止。

有任何想法嗎?

答案1

當我遇到這個問題時,我發現我需要將這些行添加到~/.ssh/config

Host *
    ForwardX11Trusted yes

您應該將 * 修改為某種主機模式,這樣就不會為每個 ssh 連線啟用它。

您可能想要變更 ForwardX11Timeout 選項。從man ssh_config

 ForwardX11Timeout
    Specify a timeout for untrusted X11 forwarding using the format
    described in the TIME FORMATS section of sshd_config(5).  X11
    connections received by ssh(1) after this time will be refused.  The
    default is to disable untrusted X11 forwarding after twenty minutes has
    elapsed.

 ForwardX11Trusted
    If this option is set to “yes”, remote X11 clients will have full
    access to the original X11 display.

    If this option is set to “no”, remote X11 clients will be considered
    untrusted and prevented from stealing or tampering with data belonging
    to trusted X11 clients.  Furthermore, the xauth(1) token used for the
    session will be set to expire after 20 minutes.  Remote clients will
    be refused access after this time.

相關內容