82

Hey I'm having an issue getting ssh X forwarding to work. The setup is I'm sshing into my ubuntu VM off OSX Yosemite host machine.

I already installed xQuartz on OSX, xauth on ubuntu, and I believe I've have all the correct options set in ssh_config files.

I get the

Warning: untrusted X11 forwarding setup failed: xauth key data not generated
X11 forwarding request failed on channel 0

message when opening a connection with ssh -X, and when I tried to run an X application:

xterm: Xt error: Can't open display:
xterm: DISPLAY is not set

I have the identical setup on my other machine except running Mavericks and it works fine, is there something specific to Yosemite specific I have to worry about?

0

10 Answers 10

91

Note that some incomplete answers might lead to security flaws.

  1. Using ssh -Y means here having fake xauth information which is bad!
  2. ssh -X should work since XQuartz, once enabled, uses xauth. The only problem is that ssh is looking for xauth in /usr/X11R6/bin and on macOS with XQuartz it is in /opt/X11/bin

Secure solution:

  1. Enable the first option in the Security tab of preferences (Cmd-,) which enables authenticated connections.

  2. Edit ~/.ssh/config, add XAuthLocation /opt/X11/bin/xauth to the host config.

  3. ssh -X your_server works in a secure manner.

  4. Ensure xauth is installed on the destination host.

6
  • 2
    @TobySpeight This answer solved my OSX->Linux login problem. As far as I am concerned it was very helpful. Upvoted. Commented Feb 21, 2018 at 8:21
  • This fixed my X forwarding after it was broken by upgrade to OSX High Sierra Commented Mar 28, 2018 at 20:20
  • 1
    Does not work on OSX Mojave, but @XValidated's answer below successfully connects, though a warning about missing xauth data is shown.
    – taranaki
    Commented Oct 21, 2019 at 17:19
  • I tried this on Mojave and it made ssh -X ... just hang.
    – interfect
    Commented Feb 25, 2020 at 0:19
  • After upgrading to Mojave I was getting the error in the OP. This fixed the issue.
    – matt
    Commented Apr 24, 2020 at 8:00
60

On macOS Sierra, I now have to do ssh -Y instead of ssh -X to get a display from a linux machine to work on my Mac.

1
  • 2
    This may solve the issue, but it also enables trusted forwarding instead of the more secure trusted one. @Koko's answer fixed it for me without having to use "-Y" instead of "-X" which is preferable.
    – francoisr
    Commented Oct 30, 2018 at 10:47
42

I received the same warning as you after upgrading to Yosemite. After I added ForwardX11Trusted yes in my ~/.ssh/config file, the warning disappeared.

Do you have the following lines in your ~/.ssh/config file for enabling Trusted X11 forwarding?

Host APPROPRIATE_HOSTNAME
    ForwardX11Trusted yes
    ForwardX11 yes
    OTHER_OPTIONS
7
  • 2
    Good to hear someone got it working. Which side of the ssh are you talking about? I have that in my ~/.ssh/config on ubuntu.
    – sprw121
    Commented Jan 8, 2015 at 7:09
  • 3
    I no longer get the warning, but I still get X11 forwarding request failed on channel 0
    – sprw121
    Commented Jan 8, 2015 at 7:19
  • 1
    the ssh settings should be adjusted on the "client" side, i.e. your Mac machine because you are trying to ssh from your Mac to use the host ubuntu VM machine. (and why do you want to ssh to a ubuntu VM?)
    – XValidated
    Commented Jan 9, 2015 at 0:44
  • Works for macOS High Sierra Commented Oct 31, 2017 at 13:23
  • I'm getting same warning in Redhat and changing the config file in /etc/ssh/ssh_config did the trick. Thankyou Commented Apr 18, 2018 at 15:24
13

Gilles Gouaillardet has the answer that solved this for me. Edit ~/.ssh/config to contain

Host *
    XAuthLocation /opt/X11/bin/xauth

and ssh -X hostname now works (XQuartz 2.7.11, macOS 10.4 Mojave)

1
  • xauth is needed on destination host too by the way Commented Jan 13, 2019 at 21:06
7

I already had the latest XQuartz 2.7.11 installed, but I think I've also updated the OS a few times since then. I reinstalled XQuartz 2.7.11, and now it is working fine.

2
  • Good find - reinstalling the same (latest) version of XQuartz worked for me too
    – sonofagun
    Commented Jun 16, 2017 at 23:17
  • I also had to do this; I hadn't tried to use X forwarding since upgrading macOS, and although XQuartz would start up fine, forwarding wouldn't work. This worked when none of the other answers did.
    – interfect
    Commented Feb 25, 2020 at 0:29
1

ForwardX11Trusted is required even for connections you think are untrusted when your X server doesn't have the SECURITY extension (Apple servers have a ton of visuals that take up over 100 lines, so I suggest "xdpyinfo | grep SECURITY" to check; if that returns no output, you don't have it). There may be other reasons and exceptions, but this worked for me.

0

I've just downloaded the latest X11 version and it worked again

0

I just hit this issue using Mac OS X 10.6.8 to Linux Debian 9. None of the solutions provided worked.

Root cause was: loopback interface was "DOWN" on the target Linux host.

I had to type the following on the target host to fix the issue

ip link set lo up

0

Same as answered by user Xvalidated above. but there was no ssh_config file in my .ssh directory. 1. copy ./etc/ssh_config to ~/.ssh/ #file if not there 2. edit Host hostname ForwardX11Trusted yes ForwardX11 yes

  1. As answered before, I would like to add one more thing which will work to reinstall X-supporting software.
-4

When you login the cluster, do not use -X or -Y options.

Example:

ssh -Y remotelogin: gives me X11 related warning. 

ssh remotelogin: No warning, works fine.

2
  • -X is not always neccessary Commented Jan 13, 2019 at 21:05
  • So...if you don't need remote X, then don't use -X, got it :)
    – rogerdpack
    Commented Feb 5, 2019 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.