Changing UIDs and X Forwarding with SSH

Tunneling X over SSH is simple:

$ ssh -X [hostname]

But if you have to su to another user, you may have seen this:

$ sudo su -
# xterm
X11 connection rejected because of wrong authentication.
X connection to localhost:10.0 broken (explicit kill or server shutdown).

Some commands will still work if you don’t load up the new user’s environment, (using a “su” rather than “su -”) but you will still have some problems.

The problem is caused by xauth, and the easiest thing to do is merge in the Xauthority cookies form the previous UID:

$ sudo su -
# xauth merge ~[username]/.Xauthority
# xterm

All X applications should now correctly open on you client machine.

0 Responses to “Changing UIDs and X Forwarding with SSH”


  • No Comments

Leave a Reply