Comment 3 for bug 471726

Revision history for this message
Robert C Jennings (rcj) wrote :

I found a way to make x2x work, I wouldn't call it a solution but it points to what is missing when you get this error. The xauth authority file used when tunneling X through ssh does not have the cookie for the X server.

Setup:
 - 2 machines, called 'desktop' and 'laptop' where x2x is run on the laptop.
 - Run 'ssh -XC laptop x2x -east -to :0.0' from desktop
 - Error seen: 'x2x - error: can not open display :0'

From the desktop:
# ssh -X laptop 'xauth info'
Authority file: /home/user/.Xauthority
File new: no
File locked: no
Number of entries: 2
Changes honored: yes
Changes made: no
Current input: (argv):1

# ssh -X laptop 'xauth list'
laptop/unix:10 MIT-MAGIC-COOKIE-1 84924c4306f8234702fe1cec2c821c8f

From the laptop:
# xauth info
Authority file: /var/run/gdm/auth-for-user-w9KmhU/database
File new: no
File locked: no
Number of entries: 1
Changes honored: yes
Changes made: no
Current input: (argv):1

# xauth list
laptop/unix:0 MIT-MAGIC-COOKIE-1 007d71f327f9cf279ff3c5fb9d21b5a7

At this point the ssh session from the desktop to the laptop has a cookie for display :10 only. So the message regarding a failure to open :0 isn't a big surprise. I resolved this by running the following from the desktop:

# ssh -X laptop 'xauth merge /var/run/gdm/auth-for-user-w9KmhU/database'

After this is run, you can check that the cookie has been added for :0 by running:

# ssh -X laptop 'xauth list'
laptop/unix:0 MIT-MAGIC-COOKIE-1 007d71f327f9cf279ff3c5fb9d21b5a7
laptop/unix:10 MIT-MAGIC-COOKIE-1 84924c4306f8234702fe1cec2c821c8f

From there I can run:

# ssh -X laptop 'x2x -east -to :0.0'

Here's the caveat, the cookie (and the file it's stored in) for :0 changes each time you log in on the remote machine (in this case, 'laptop'). Here's the output on the laptop after logging out and back into X.

# xauth info
Authority file: /var/run/gdm/auth-for-user-u4JpYD/database
File new: no
File locked: no
Number of entries: 1
Changes honored: yes
Changes made: no
Current input: (argv):1

# xauth list
laptop/unix:0 MIT-MAGIC-COOKIE-1 149afc922a496cae086650e10f113bf5

At this point, the command 'ssh -X laptop x2x -east -to :0.0' will again fail. I cleaned up by running 'ssh -X laptop xauth remove laptop/unix:0' so that I only had a cookie entry for :10 at this point.

I don't have a real solution, but I hope this helps improve the understanding of the problem.