With SSH X11 forwarding (`ssh -X`), get `Can't open display` trying to run X applications

Опубликовано: 09 Август 2020
на канале: Roel Van de Paar
182
1

Unix & Linux: With SSH X11 forwarding (`ssh -X`), get `Can't open display` trying to run X applications


The Question: I'm able to login to sever using
ssh -X Hostip
but when i run the command xclock it give me this error
Error: Can't open display: localhost:11.0
I check my Display value using
echo $DISPLAY
and the result is
localhost:11.0
And X11 forwarding is set to YES in sshd_config file
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
Any advice what I'm missing here?

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 18 people ==
Use -Y. From the man page on ssh:
-Y Enables trusted X11 forwarding. Trusted X11 forwardings are not
subjected to the X11 SECURITY extension controls.
If you're still having problems though, you can try setting_$DISPLAY_to_your
local_box's_IP:
$ export DISPLAY='<ip_address>:11.0'
It may work to set it as
$ export DISPLAY='127.0.0.1:11.0'
People seem to have this problem commonly when https://superuser.com/a/443175/
195019. You may also want to set
X11UseLocalhost no
in this case as well.

== This solution helped 6 people ==
this worked for me:
Change
X11UseLocalhost yes
to
X11UseLocalhost no

== This solution helped 3 people ==
When trying to forward to XQuartz on macOS, I fixed the issue by running the
ssh command (ssh Y in my case) from the XQuartz terminal (opened by right
clicking the XQuartz icon in the dock and clicking Applications > Terminal).

== This solution helped 6 people ==
Credit to https://unix.stackexchange.com/a/1277... for their diagnostic
instructions.
Ensure you're ssh client is requesting X11 Forwarding with the -v flag
ssh example.com -X -v
And look for thespecific message:
debug1: Requesting X11 forwarding with authentication spoofing.
Another telltail problem sign is the lack of the DISPLAY environment variable
beign set for you. If its blank/unset, there is something wrong. At least
according to https://unix.stackexchange.com/a/1277..., these variables are
set for you automatically.
----
I was using an SSH Control Master my ssh connections like so:
Host <hostname>
ControlMaster auto
ControlPath ~/.ssh/control/%r@%h:%p
ControlPersist 10m
My earlier ssh connection did not request X11Firwarding, therefore future ssh
call's options weren't being used. So for me,
ssh -X was just being ignored altogether
If you aren't seeing "Requesting X11 Forwarding", but you do see the muxer
reusing sessions;
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 10
Then you need to exit your current ControlMaster for that connection and
reconnect with the -X/-Y flag.
To Stop your ControlMaster
ssh -O check <hostname>
Master running (pid=2758)
(This will exit all active connections using the ControlMaster)
ssh -O exit <hostname>
Exit request sent.

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free... | Images: https://stocksnap.io/license & others | With thanks to user ThorSummoner (https://unix.stackexchange.com/users/..., user OmiPenguin (https://unix.stackexchange.com/users/..., user Mostafa (https://unix.stackexchange.com/users/..., user Kyle Kelley (https://unix.stackexchange.com/users/..., user Harry Cutts (https://unix.stackexchange.com/users/..., user don (https://unix.stackexchange.com/users/..., user Anthon (https://unix.stackexchange.com/users/..., user a CVn (https://unix.stackexchange.com/users/..., and the Stack Exchange Network (http://unix.stackexchange.com/questio.... Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.


Смотрите видео With SSH X11 forwarding (`ssh -X`), get `Can't open display` trying to run X applications онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Roel Van de Paar 09 Август 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 18 раз и оно понравилось людям.