I'm ssh'd into a remote computer and xforwarding is working fine... but as soon as I "sudo su -" or "sudo su user2" it no longer Xforwards anything giving me the error:

X11 connection rejected because of wrong authentication.
xterm Xt error: Can't open display: localhost:10.0

Any Ideas?

Thanks

link|improve this question

1  
this is more due to X permissions than X forwarding -- the user you've logged into with SSH has permission to connect to the X display, but when you switch users with 'sudo' the user you're switching to doesn't have those permissions. – quack quixote Apr 15 '10 at 0:54
There should be a work around though... I have root access, I should be able to run an X11-forwarded app as a different user. How do I get it to work? – Dan Apr 15 '10 at 13:41
feedback

2 Answers

Before you sudo, do this:

$ xauth extract /tmp/xauthstuff $DISPLAY

After you sudo, do this:

# xauth merge /tmp/xauthstuff

Does this work for you?

PS remember to rm /tmp/xauthstuff afterwards

link|improve this answer
1  
I tried that command and it failed: $ xauth extract /tmp/xauthstuff $DISPLAY No matches found, authority file "/tmp/xauthstuff" not written Ideas? – djb Mar 31 '11 at 13:07
feedback
  1. Enable X-11 Forwarding in your client
  2. Log in as your normal user
  3. echo $DISPLAY to get the associated display
  4. xauth list, find the display number which corresponds with what you found in #3 and copy it
  5. Sudo to root xauth add <paste in what you copied from #4>
  6. Now you can execute commands as root and will be able to se the X11 Forwarding connection
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.