如何知道使用 ssh 时变量 DISPLAY 将导出哪个显示号码?

如何知道使用 ssh 时变量 DISPLAY 将导出哪个显示号码?

当我ssh使用 连接到服务器时-X,我总是对应该导出哪个显示号码感到困惑。有时我觉得显示号码已被某些东西使用,所以我能做的就是查看:

export DISPLAY=localhost:0 && xclock  
export DISPLAY=localhost:1 && xclock  
export DISPLAY=localhost:2 && xclock  
export DISPLAY=localhost:...

直到出现时钟。然后我将使用该显示号码。每次我登录服务器时,能够正确传输 GUI 数据的显示号码都会有所不同。

答案1

当启用 X 转发时,sshd 会$DISPLAY在服务器端自动设置;您没有理由覆盖其值。

相关内容