X11 forwarding requested but DISPLAY not set
Asked Answered
M

4

10

I want to enable x11 forwarding on macOS connected to a Jetson Xavier nx. However, upon connecting:

sudo ssh -Xvvv id@host

The connection establishes successfully. But in the verbose logs, I'm getting the following:

debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to proto1 ([192.168.1.106]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: exec
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug1: X11 forwarding requested but DISPLAY not set
debug2: fd 4 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x48
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug3: Ignored env TERM
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env PATH
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env HOME
debug3: Ignored env MAIL
debug3: Ignored env LOGNAME
debug3: Ignored env USER
debug3: Ignored env SHELL
debug3: Ignored env SUDO_COMMAND
debug3: Ignored env SUDO_USER
debug3: Ignored env SUDO_UID
debug3: Ignored env SUDO_GID
debug3: Ignored env __CF_USER_TEXT_ENCODING
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0

X11 forwarding requested but DISPLAY not set

And in order for X11 forwarding to work, the DISPLAY variable must be set upon connection. Manually setting the DISPLAY like so:

export DISPLAY=http://localhost:22

doesn't work either. How to enable X11 forwarding?

Maupassant answered 28/8, 2020 at 1:27 Comment(0)
D
14

I had the same problem trying to get X11 forwarding to XQuartz. I believe when you ssh from Mac, if DISPLAY in the Mac terminal is not set, then the ssh client does not know where to forward the X11 traffic. So I just did:

DISPLAY=:0

in the Mac terminal, then ssh -X and it worked.

Diversified answered 30/7, 2021 at 4:48 Comment(3)
This works. I can be seen by comparing the environment (env command) of an XQuartz terminal and an iterm2 or Mac OS default terminal environment.Triplane
+1, the DISPLAY variable is not set in the Mac terminal by default. After setting it with export DISPLAY=:0, it gets forwarded to the remote server with ssh -X or ssh -Y and everything works as expected. Alternatively, one can ssh using the terminal that comes with XQuartz as it has the DISPLAY variable set by default.Karyolysis
This also works on windows 10 ssh (with an X server like VcXsrv). set DISPLAY=<ip>:0.0 and then ssh -YLackey
D
6

Well there should definitely not be an http:// in there, and I think your :22 came from the SSH port and is not an X11 display number you should be using. Your DISPLAY on the local machine is almost always :0.0, and if you don't already see that when you echo $DISPLAY on your machine, something is probably wrong there.

Make sure you can run X11 applications on your Mac alone first. You may need to install XQuartz.

Try running without sudo; maybe root isn't allowed to talk to your X11 on Mac. Also, maybe try ssh -X from within an xterm window (which should open up when you open XQuartz manually, or be launchable from its menus) to make sure it picks up the right DISPLAY.

Dramatics answered 28/9, 2020 at 16:56 Comment(0)
B
3

I met the same problem earlier. It turns out I didn't install X11 forwarding packages on my Mac. So make sure you installed XQuartz by brew:

brew install xquartz --cask

(Notice that the error message can be like yours when xquartz is not installed on your Mac, so check on your local machine first.)

Then make sure you have export DISPLAY=:0, or you can check the $DISPLAY by echo $DISPLAY. After that, by using verbose ssh -v -X user@host, you should find debug message like:

debug1: Requesting X11 forwarding with authentication spoofing.

That worked for me. Though the eog command shows with slow speed later.

Brenda answered 30/6, 2023 at 7:3 Comment(0)
T
0

I followed Scott's instructions above and installed xquartz from homebrew:

brew install xquartz

I then tried setting DISPLAY=:0 from Sasha's answer.

Unfortunately, doing the two steps above is not enough to get your Mac configured to receive X11 from the host. You also need to reset your computer to have DISPLAY set as a global environment variable.

You can test this by running printenv DISPLAY. After installing xquartz and restarting my computer, it should look something like this:

$ printenv DISPLAY
/private/tmp/com.apple.launchd.XJa3QdBpuk/org.xquartz:0

After doing this, as well as enabling X11 forwarding on the host, ssh -Y <hostname> worked for me as expected.

See this issue on the Apple Community Boards for more details

Traceytrachea answered 11/8, 2024 at 5:8 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.