【发布时间】:2020-10-03 14:02:06
【问题描述】:
我正在尝试使用 mac 上的 ssh 转发功能在本地显示远程 GUI 应用程序。
在 Mac 上,我安装了官方的 xserver XQaurtz,设置如下。
$ cat ~/.ssh/config
Host *
XAuthLocation /opt/X11/bin/xauth
ForwardAgent yes
ForwardX11 yes
然后我用“ssh -v -X user@remote_machine”登录ubuntu机器,然后用xclock进行测试。
$ ssh -v -X user@remote_machine
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data ~/.ssh/config
debug1: /Users/bwu/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: /etc/ssh/ssh_config line 52: Applying options for *
debug1: auto-mux: Trying existing master
在远程机器上,由于 $DISPLAY 为空,xclock 无法启动。
$ xclock
Error: Can't open display:
我又做了两个测试。
从同一个 mac,ssh 登录到另一台 centos 7 机器,它正在工作。 $ cat /etc/ssh/sshd_config X11Forwarding 是 X11DisplayOffset 0
从 ubuntu 主机, ssh 登录到上面的 ubuntu 机器,它正在工作。 $ cat /etc/ssh/sshd_config X11Forwarding 是 X11DisplayOffset 0
所以我们得到了以下结果。
mac to centos, working ubuntu to ubuntu, working mac to ubuntu, not working
Test 1 indicates the issue might locate on remote ubuntu machine.
Test 2 indicates the issue might locate on local mac machine.
这有什么问题?我错过了什么吗?
【问题讨论】:
-
你可以试试可信的X11转发吗?
ssh -v -Y user@remote_machine -
我以为我之前尝试过,但都没有用。刚刚又试了一次,'ssh -v -Y' 显示了更多信息,然后我尝试了'ssh -v -X',这次它可以工作了。它还显示了更多消息,尤其是“debug1: Requesting X11 forwarding with authentication spoofing。”。以前的尝试从未看到此“请求 X11”消息。对此感到困惑,不知道发生了什么。
-
它不再工作了,疯了。 >$ ssh -v -Y user@remote_machine >OpenSSH_7.9p1, LibreSSL 2.7.3 >debug1: 读取配置数据 /Users/bwu/.ssh/config >debug1: /Users/bwu/.ssh/config line 1: Applying * >debug1 的选项:读取配置数据 /etc/ssh/ssh_config >debug1:/etc/ssh/ssh_config 第 48 行:应用 * >debug1 的选项:/etc/ssh/ssh_config 第 52 行:应用 * >debug1 的选项:自动多路复用器:尝试现有的主 >$ xclock >错误:无法打开显示:本地主机:0.0 >$ echo $DISPLAY >本地主机:0.0