环境细节
服务器 /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
当我以用户身份登录时,我可以让 X11Forwarding 工作vagrant
。当我以用户身份登录时,我无法让 X11Forwarding 工作ops
。
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
如果我以和 then身份登录sudo su - vagrant
,则$DISPLAY
保持未设置。如果我登录为vagrant
然后sudo su - ops
,$DISPLAY
则被继承。
我缺少什么让这个工作?我已经xhost +
在每个用户(包括sudo -s root 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