Environmental Details
Relevant bits of server's /etc/ssh/sshd_config:
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
Relevant bits of client's $HOME/.ssh/config:
Host *
XAuthLocation /opt/X11/bin/xauth
ForwardX11 yes
ForwardX11Trusted yes
Using XQuartz on macOS High Sierra.
The Problem
I'm spinning up a vagrant Ubuntu 18.04 VM. I've added a second user outside of the vagrant
user.
ssh -X vagrant@ubuntu-bionic xclock
I can get X11Forwarding to work when I login as the vagrant
user. I cannot get X11Forwarding to work when I login as the ops
user.
ssh -X ops@ubuntu-bionic xclock
X11 forwarding request failed on channel 0
Error: Can't open display:
I want to be able to get it to work with the ops
user. From the client, $DISPLAY
has a value. When I login with vagrant
, $DISPLAY
has a value. When I login as ops
, $DISPLAY
is unset. If I set $DISPLAY
to match what it is with the vagrant
user, I get the same error:
Error: Can't open display: localhost:10.0
when X11UseLocalhost yes
Error: Can't open display: ubuntu-bionic:10.0
when X11UseLocalhost no
If I login as ops
and then sudo su - vagrant
, $DISPLAY
remains unset. If I login as vagrant
and then sudo su - ops
, $DISPLAY
is inherited.
What am I missing to get this to work? I've run xhost +
in each user (including sudo -s root xhost +
) and it still doesn't work.
If I add -vv
to my ssh commands, I see this message when connecting as vagrant
:
X11 forwarding request accepted on channel 0
and as ops
:
Remote: X11 forwarding disabled in user configuration file.
X11 forwarding request failed on channel 0
~ops/.ssh/config
file? (ie, in/home/ops/.ssh/config
) any differences between that and the one in thevagrant
users' home dir? – Heterophytevagrant
/ops
home directories don't currently have a~/.ssh/config
file. – Argalivagrant
/ops
have the contents of the~/.ssh/config
referenced at the top of the post. Still not working. – Argali