80

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?

sprw121
  • 1,073
  • 1
  • 8
  • 8

10 Answers10

90

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.

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
Koko
  • 1,019
  • 7
  • 2
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.

ST3
  • 8,826
  • 3
  • 68
  • 92
Chris Jacobsen
  • 617
  • 5
  • 2
  • 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 Oct 30 '18 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
Vampire
  • 35,631
  • 4
  • 76
  • 102
XValidated
  • 981
  • 8
  • 12
  • 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 Jan 08 '15 at 07:09
  • 3
    I no longer get the warning, but I still get X11 `forwarding request failed on channel 0` – sprw121 Jan 08 '15 at 07: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 Jan 09 '15 at 00:44
  • Works for macOS High Sierra – Nigel Tufnel Oct 31 '17 at 13:23
  • I'm getting same warning in Redhat and changing the config file in `/etc/ssh/ssh_config` did the trick. Thankyou – Gangadhar Jannu Apr 18 '18 at 15:24
  • @sprw121 For `X11 forwarding request failed on channel 0` in my case, I did a `yum install xauth` on the remote server, then that particular message went away...and was replaced with `connect /tmp/.X11-unix/X0: No such file or directory` which meant this https://unix.stackexchange.com/a/429812/8337 – rogerdpack Feb 05 '19 at 20:07
  • Works on OSX Mojave, though a warning about missing xauth data is shown (for some machines but not for all; not sure why). – taranaki Oct 21 '19 at 17:20
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)

shepster
  • 339
  • 3
  • 13
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.

Ulmo
  • 71
  • 1
  • 1
  • Good find - reinstalling the same (latest) version of XQuartz worked for me too – sonofagun Jun 16 '17 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 Feb 25 '20 at 00: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

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Laurie
  • 53
  • 9
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

kalou.net
  • 446
  • 1
  • 4
  • 16
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.
Manish
  • 1
  • 1
-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.

Dmitriy
  • 5,525
  • 12
  • 25
  • 38
Raju
  • 36
  • 2