3

I'm trying to forward my X windows, but seems to be limited to just on session?

What I'm trying to do is invoke x-applications as another user, through a sudo su -.

If I know the other user's password, than this is easily resolve with:

ssh -Y user@host
password:  ********
gedit &

However, if running a user which I do not have a password (weblogic, for example):

ssh –Y me@host
xauth list

sudo csh (now root)
xauth add (last line of the xauth list above)
gedit &

HOWEVER, I'm having trouble allowing another user to access the x display:

xauth list
su – weblogic
xauth add (last line of the xauth list above)
gedit (see if gedit launches).

This fails.

I've also attempted to go direct to the to the other user via sudo:

ssh –Y me@host
xauth list
sudo su – weblogic
xauth add (last line of the xauth list above)
gedit (see if gedit launches).

This too fails.

  • Are your machine and the guest user's machine on the same network/subnet ? – MelBurslan May 24 '16 at 20:09
  • Same machine. However, I ssh into the server using my NIS+ account, then attempt to run in installer as a "local" user. – leonhardtk May 24 '16 at 20:58
2

The problem is probably that su - will clear all the environment variables except TERM, so you will lose the DISPLAY setting. Try setting DISPLAY=localhost:10.0 (for example) before the gedit.

  • Aha! While I had already tried what you had described before writing the post. However, after reading your response and attempting again I found an inconsistency (well, from my perspective anyway!) In my case, root display is :13, but the error I was getting was that it couldn't open the display for localhost:11. Therefore, I looked at root's "xauth list" and found the cookie for the host's :11 display. did the xauth add to that cookie (as the new user) and I'm in business. – leonhardtk May 24 '16 at 20:50
  • Also, I'll have to check on your statement, "su - will clear all the environment variables except TERM", my assumption all these years is that su - will create a login shell, and would actually source the user's shell appropriate resource control file (i.e., csh --> .cshrc, bash --> .bashrc, etc.)? – leonhardtk May 24 '16 at 20:57
  • Sure, I just meant su - starts by clearing the env, but then it goes on to read the startup files you mention, which dont usually set DISPLAY. – meuh May 24 '16 at 21:03
  • Using xauth list $DISPLAY should ensure you get the right entry. – meuh May 24 '16 at 21:14
  • Okay, I've done this several times, and it working...seems so easy now, but was fighting this all morning! Though, not technically the right answer (I'm not actually setting the DISPLAY variable, but adding the "Correct" xauth;) Your localhost:10.0 highlighted that I was using the wrong display! Therefore, will mark this as correct! Thanks a million! KSL. – leonhardtk May 24 '16 at 21:14
1

If you get the following error: xauth: file /root/.Xauthority does not exist in response to the xauth add command (e.g., xauth add :15.0) just touch the file (touch /root/.Xauthority)

0

I'm using statements like

su -s /bin/bash -c "xauth add $(xauth -f ~/.Xauthority list|tail -1); cd ~; VirtualBox" vbox

Replace VirtualBox by the software you want to run and don't forget to change vbox to your desired identity :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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