我正在尝试在 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:
我又做了两个测试。
From the same mac, ssh login to another centos 7 machine, it's working. $ cat /etc/ssh/sshd_config X11Forwarding yes X11DisplayOffset 0
From a ubuntu host, ssh login to above ubuntu machine, it's working. $ cat /etc/ssh/sshd_config X11Forwarding yes 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 转发在 centos 或 ubuntu(来自我的 macbook)上“随机”不起作用,但几个小时后它可能会再次起作用。
我检查了centos和ubuntu上的sshd配置,没什么特别的,它们在x11转发部分是一样的。我不知道为什么。
X11Forwarding yes
X11DisplayOffset 0
#X11UseLocalhost yes
关于macos - 从 mac 到 ubuntu 的 ssh 转发不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62366533/