macos - 从 mac 到 ubuntu 的 ssh 转发不起作用

标签 macos ubuntu ssh centos

我正在尝试在 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:

我又做了两个测试。

  1. From the same mac, ssh login to another centos 7 machine, it's working. $ cat /etc/ssh/sshd_config X11Forwarding yes X11DisplayOffset 0

  2. 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/

相关文章:

eclipse - Eclipse JDK设置如何影响系统的JDK设置

java - 如何从 Java Swing 应用程序运行 OSX 字符查看器

windows - 在 Windows 和 Linux/Ubuntu 上运行的基准测试软件

android - GIGABYTE 的 USB 供应商 ID

android - scp/secure 从远程 android 设备/SSH 服务器复制最新文件

ssh - 如何登录ec2机器?

ios - (在iOS/OS X SDK中)__i386__和__x86_64__在哪里定义?

swift - 如何模拟从 Mac App 到其他应用程序的鼠标点击

python - 导入错误 : No module named bz2 for Python 2. 7.2

git - 使用 SSH 接受公钥,使用 git 失败