Announcement

Collapse
No announcement yet.

Getting X11 to work in sudo and ssh

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting X11 to work in sudo and ssh

    I'd like to be able to do something like this:

    Code:
    me@mymachine:~$ sudo su -
    Password:
    root@mymachine:~# kwrite test.txt
    and have KWrite come up. However, I get this error:
    Code:
    kwrite: cannot connect to X server
    Also, I'd like to be able to do this as well:
    Code:
    me@mymachine:~$ ssh someuser@somemachine
    someuser@somemachine's password:
    ...
    [someuser@somemachine ~]$ kwrite test.txt
    But I get the exact same error

    How do I setup sudo to work with my desktop? As for ssh, I can get that to work if I remember to pass in -X to the ssh command. However, I didn't have to do this with my Mandrake install, so what's the difference?

    Thanks,
    Anodos






    #2
    Re: Getting X11 to work in sudo and ssh

    In fact, you can do it in 2 ways :
    kdesu kwrite test.txt
    or
    ssh -X someone@somemachine

    Hope it helped

    Comment


      #3
      Re: Getting X11 to work in sudo and ssh

      An explanation (this is how I see it, at least): When you sudo <command>, the system executes that command as if the user root has entered it. So if that command involves a program interacting with X (the windowing system), it looks for the X server that root is logged on to... and of course it doesn't find it because root is not logged on to an X server. Using kdesu avoids this problem.

      Ah, the joy of X-forwarding over SSH! If -X doesn't work try -Y.

      Comment

      Working...
      X