Thursday, January 22, 2009

How to get rid of the "no XAuth data" msg from 'ssh -Y'

I use SSH a lot. Quite often I use X11 forwarding to open up graphical applications from the remote host. But one of the most common warning messages printed by the SSH client is this:

Warning: No xauth data; using fake authentication data for x11 forwarding

Luckily, this can be fixed with two quick commands.


When forwarding X over ssh, "untrusted" mode (i.e. the -X option) can have some subtle limitations. For example:
1. start local xterm
2. ssh -X $HOST
3. start xterm from remote shell
4. select text from remote xterm
5. paste to local xterm
6. See the error
This seemed like an odd error to me, and it was a unique combination of actions that caused it in this particular case. But this error is quite common when forwarding your X session over SSH.

One solution is to forward X in "trusted" mode: ssh -Y ...

However, this can result in the following warning:
Warning: No xauth data; using fake authentication data for x11 forwarding
Which is another message that tends to pop up when forwarding X.

The best solution to this problem is to generate the X authentication data for the current display, and send it to the remote host. When the remote host has correct X authentication data, these errors go away.


HOST=[ssh server]
xauth add :0 . $(mcookie) # only once per display
xauth nlist :0 | ssh $HOST xauth nmerge -

No comments: