How to open an application in running X session

0

Is there any way to do that? Provided I have ssh access to a machine and I have root on the machine. Can I run xclock for instance in the currently running X (xfce or gnome) session?

user1594980

Posted 2013-06-02T19:34:35.563

Reputation: 103

Question was closed 2013-06-05T15:27:36.827

1You'll need xforwarding enabled in the /etc/ssh/sshd_config (if I recall) and to launch the ssh session with ssh -X user@host. Then you can call xclock &, though it may take a sec to launch. – nerdwaller – 2013-06-02T20:32:19.283

Like @nerwaller wrote you'll need X11 forwarding. How to use it is described in more detail here.

– wottis – 2013-06-02T22:08:11.300

That is actually something different. I need to run the xclock not in my X session (X forwarding), but in the X session that is actually running on the remote machine. To make it simple, I just want to open a browser (for instance) to the person, who is actually operating with the PC I have access and root to. – user1594980 – 2013-06-03T14:49:16.173

Answers

3

You would need to have their xauth token added to your authorization file, and set your DISPLAY accordingly.

First set the DISPLAY variable to the proper X display, since it's the local display it is probably just :0.0 so:

$ export DISPLAY=:0.0

Then import the user's xauth token into yours:

$ xauth merge ~user/.Xauthority

Once you have done that you should be able to run an X client and it will show up on the correct display:

$ xclock &

If your userid has access to the user's ~/.Xauthority then you can do this without being root. But the default permissions for the ~/.Xauthority file is 0600 so likely you'll need to do all this as root.

Hope this helps.

Michael

Posted 2013-06-02T19:34:35.563

Reputation: 66

Or the user allows him to open programms in his session. Which is answered here. Is it possible to merge both questions. Because the later one describes it more clearly or should it be tagged as duplicate instead?

– wottis – 2013-06-04T21:23:40.413