When I use ssh -X
on my Mac (running OS X 10.6.7) to connect to my Ubuntu (11.04) box, I get the following warning:
Warning: untrusted X11 forwarding setup failed: xauth key data not generated Warning: No xauth data; using fake authentication data for X11 forwarding.
Is there something I can do to make this warning go away? If not, can I safely ignore it?
X11 forwarding seems to work fine, though I do see this message:
Xlib: extension "RANDR" missing on display "localhost:10.0".
Is that related to the warning? (I'm guessing not. If it's not, I'll file a new question about that.)
Try ssh -Y
Any reason you don't want to use the
-Y
flag instead of the-X
flag?Quite simply, the difference between
-X
and-Y
is that-Y
enables trusted X11 forwarding.BEWARE (tired of reading incomplete answers which lead to security flaw)
using ssh -Y means here having fake xauth information which is bad!
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 solving:
Enable the first option in Security tab of preferences (Cmd-,) which enables authenticated connections
add the following to
$HOME/.ssh/config
XAuthLocation /opt/X11/bin/xauth
ssh -X you_server
works in a secure manerIf you're coming here in 2015: even if everything else is set up properly, this can also happen on Mac OS X 10.10 Yosemite, when using
ssh -X
and running an XQuartz version <= 2.7.7. The root cause is X11 display sockets getting written outside of the xauth search path: issue #2068 in the XQuartz tracker.Edit: A fixed XQuartz has since been released at the new homepage, xquartz.org, and installing the latest version from there (currently 2.7.9) will work around the issue.
If you get the same message even when using
-Y
, thexauth
program might be missing on the server. On Debian-like systems, you need thexauth
package. On RedHat-like systems, you need thexorg-x11-xauth
package."Untrusted" in this context means you don't trust the connection. SSH will use additional security measures to try to make X11 forwarding safer. "Trusted" means you are entirely confident that no on on the remote host will get access to your Xauth data and use it to monitor your keystrokes for instance.
This terminology actually confused me for years. I thought "Trusted" connections were safer. But actually it's an option you're supposed to use in situations where the connection IS trustworthy and you want to run stuff without extra security measures getting in your way. "Untrusted" is the one that makes it (somewhat) safer to deal with an untrusted remote host.
An "Untrusted" connection attempts to limit what a black hat could do to you by engaging the X11 security extension and disabling other extensions that you (hopefully) don't need. This is probably why RandR is disabled with -X. Do you need to be able to rotate your X display from the remote host?
It's also important to note that "untrusted" X11 forwarding turns off after a certain amount of time to keep you from accidentally leaving it on. New attempts to open windows will just fail after that. That bit me several times before I read enough docs to understand what was happening.
Rule out server-side problems
First, you should rule out any server-side problems. Are you able to
ssh -X
from any other host successfully? Doesssh -Y
work whilessh -X
doesn't? In either case, assume ssh + X11 is set up correctly on your server and move on to the next section.If you aren't in a position to check that (you have but your one laptop running X11, say), you can
ssh
from the server to itself using a fake session:export DISPLAY=:44
# (Bourne shell) orsetenv DISPLAY :44
# (csh / tcsh)xauth add $DISPLAY MIT-MAGIC-COOKIE-1 1234
# Bogus cookie just for this testssh -X localhost env |grep DISPLAY
Expected result: there should be a DISPLAY variable set on the remote end of the ssh-to-self session. If you get no result, your server is likely mis-configured (e.g. the X11 libraries and/or the
xauth
command could be missing; or the sshd configuration could be set to deny X11 access)On Mac: check that Xquartz is up-to-date
As per Will Angley's answer
Examine
ssh -vv -X
outputThe error message you cite is a symptom that can have many causes. Try again with
ssh -X -vv remotehost
, which should give you additional clues as to why the X11 tunnel setup failed.Do you see the following message appearing?
If so,xauth
command resides:I don't have a setup that can exhibit this behavior, so this is a shot in the dark:
The warning might be suppressed if you set
ForwardX11Trusted
to"no"
for hosts that give this warning. You can place this in either~/.ssh/config
or/etc/ssh/ssh_config
, and you can make the option specific to a particular host by includingHost <hostname>
on the line above. the<hostname>
component matches what you type on the command line (not the resolved hostname), and it can include wildcards.If installing
xauth
does not work right, one particularly annoying case could be a corrupted.Xauthority
file. This particular case allowed some X clients to work, but not others with a greater tendency to fail with newer displays. Removing and recreating the.Xauthority
file can solve that problem.As has already been explained above, the following worked for me:
Edit ~/.ssh/config to add the lines
and now ssh -X hostname works (XQuartz 2.7.11, macOS 10.4 Mojave)
Using XQuartz 2.7.11 on MacOS Catalina, I had to update my /etc/ssh/ssh_config file and add
XAuthLocation /opt/X11/bin/xauth
afterHost *
for ssh -X to work