Running Ubuntu 16.04 in host
, I have the following setup:
- a
user1
, who performed a GUI login inhost
; - a
user2
, who is asudoer
and is logged in only through a textssh
connection (ssh user2@host
).
I would like user2
to run an X application, for example xclock
, on the user1
display. From user1
perspective, this must be the same as when user1
itself runs xclock
.
The owner of the process xclock
should be user2
, because this is the user who launched it, but however this is not important.
Edit: I can use sudo
, but I can not use user1
password, which is unknown to me.
How to accomplish this?
I read this answer and this answer, but they contain no direct examples about this. I also read about ~/.Xautority
, MIT-MAGIC-COOKIE-1
and I obtained the list of cookies with xauth list
, but wasn't able to use them.
I tried, from the prompt in the ssh
connection (so, as user2
):
$ env DISPLAY=:0 XAUTHORITY=/home/user1/.Xauthority xclock
but this causes the prompt to never return. Note that, being a sudoer
, user2
is potentially able to read/copy/write the file .Xauthority
in user1
home directory. The above commands, however, don't work even when user2
and user1
are the same.
sudo su
orsudo bash
before thexclock
command?user2
may be a sudoer, but still needs to runsudo
to get root privileges. – JigglyNaga Dec 14 '18 at 17:52xclock
line just asuser2
. – BowPark Dec 14 '18 at 18:16sudo bash
and then the command. The prompt does not return. – BowPark Dec 14 '18 at 18:27xclock
exits. Doesxclock
appear on user1's display? – JigglyNaga Dec 14 '18 at 18:33xclock
doesn't appear. – BowPark Dec 14 '18 at 19:15su
would require theuser1
password, while instead I would like to usesudo
fromuser2
, so withuser2
password. It works with (I guess it is a sort of equivalent to yoursu
):
– BowPark Dec 14 '18 at 21:58sudo -u user1 DISPLAY=:0 xclock &