【发布时间】:2018-10-08 19:34:33
【问题描述】:
环境细节
服务器 /etc/ssh/sshd_config 的相关位:
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
客户端的$HOME/.ssh/config相关位:
Host *
XAuthLocation /opt/X11/bin/xauth
ForwardX11 yes
ForwardX11Trusted yes
在 macOS High Sierra 上使用 XQuartz。
问题
我正在启动一个流浪的 Ubuntu 18.04 虚拟机。我在vagrant 用户之外添加了第二个用户。
ssh -X vagrant@ubuntu-bionic xclock
当我以vagrant 用户身份登录时,我可以让 X11Forwarding 工作。当我以ops 用户身份登录时,我无法让 X11Forwarding 工作。
ssh -X ops@ubuntu-bionic xclock
X11 forwarding request failed on channel 0
Error: Can't open display:
我希望它能够与ops 用户一起使用。从客户端,$DISPLAY 有一个值。当我使用vagrant 登录时,$DISPLAY 有一个值。当我以ops 登录时,$DISPLAY 未设置。如果我将$DISPLAY 设置为与vagrant 用户匹配,我会得到同样的错误:
Error: Can't open display: localhost:10.0
当X11UseLocalhost yes
Error: Can't open display: ubuntu-bionic:10.0
当X11UseLocalhost no
如果我以ops 登录,然后sudo su - vagrant,$DISPLAY 仍然未设置。如果我以vagrant 登录,然后sudo su - ops,$DISPLAY 将被继承。
让这个工作我缺少什么?我在每个用户(包括sudo -s root xhost +)中运行了xhost +,但它仍然不起作用。
如果我将-vv 添加到我的 ssh 命令中,我会在以vagrant 连接时看到此消息:
X11 forwarding request accepted on channel 0
作为ops:
Remote: X11 forwarding disabled in user configuration file.
X11 forwarding request failed on channel 0
【问题讨论】:
-
在ubuntu机器上,
~ops/.ssh/config文件里有什么? (即在/home/ops/.ssh/config中)与vagrant用户主目录中的那个有什么区别? -
服务器
vagrant/ops主目录当前没有~/.ssh/config文件。 -
现在
vagrant/ops都有帖子顶部引用的~/.ssh/config的内容。还是不行。
标签: vagrant macos-high-sierra x11-forwarding ubuntu-18.04