Cross-Posted
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.
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
I don't get the whole topic, but for my very similar situation it helped to create the users
~/.Xauthorityfile. I copied it from the vagrant user
s home directory and then set the new ownership.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With