Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have an openSUSE machine which I log on to with ssh -X. I don't want to log in as root but I do want to run graphical Yast. Inside the ssh session sudo starts the console version of Yast. However, in Gnome or KDE it is possible to start Yast as a normal user and then give a root password in a window to run Yast as root.

How can I do that from my ssh session?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Log in as "normal" user (using X11-forward), then su - -c yast2.

share|improve this answer
    
Ta. That worked. –  Andrew J. Brehm Feb 9 '12 at 22:10
    
what if I would like to use my password (sudo) not root password? –  mpapis Aug 22 '12 at 20:21
    
@mpapis should work via sudo, too, but I did not check. sudo is more common on Debian-based systems. You might have to force TTY-allocation to make it work in a single command via ssh. –  Nils Aug 26 '12 at 20:38
    
sudo most likely has env_reset which means most of environment variables are lost, including DISPLAY, you would have to write it like sudo DISPLAY=$DISPLAY yast2, but this still does not work when ssh -Y is used as authentication to X server is lost with sudo, so any hints? –  mpapis Aug 27 '12 at 1:54

X uses a variable called DISPLAY in order to determine where to send the "information" related to the display. When you use ssh -X, SSH creates a DISPLAY variable and X programs use that.

When you use sudo, it gives you a restricted environment. To avoid this, you could try the command:

sudo -E yast

This will run yast but preserve the environment. This may or may not work depending on your sudoers settings, in particular setenv and the SETENV tag for commands (with the ALL command tag, SETENV is implied).

To just set DISPLAY (in case it doesn't transfer over), you could do this too:

sudo DISPLAY=$DISPLAY yast

This is subject to the same restrictions as the first command.

share|improve this answer
    
About the "-" sudo complains "-: command not found". Without the "-" both commands just start text-mode yast as root, not the X version. –  Andrew J. Brehm Feb 9 '12 at 7:21
    
That was a syntax error on my part (fixed above). I would try something like sudo su - and then echo $DISPLAY and see what it says. I might also try an X-only program to see what happens. If DISPLAY is set right and the access is good, it should work. You could try this sequence too: xhost +; sudo -E yast - that grants access to the display, but I don't think that's right. –  Mei Feb 9 '12 at 14:19
    
I do wonder how Yast decides whether to display X or use the console. –  Andrew J. Brehm Feb 9 '12 at 15:54
    
yast2 automatically chooses based on modules loaded and on the DISPLAY variable; check the DISPLAY variable and make sure that the display works. It is possible to login with ssh -X and have the remote SSH deny X forwarding; so check DISPLAY. Also make sure that you have the X libraries loaded on the remote system; if they're not available, it won't work. You can affect the GUI that yast2 uses through a setting in /etc/sysconfig/yast2: WANTED_GUI="gtk" (or qt). If you have X available on the remote system, try xclock and sudo xclock to see if the display actually works. –  Mei Feb 9 '12 at 16:57
    
X works for programs that run without sudo. sudo xlogo Error: Can't open display: –  Andrew J. Brehm Feb 9 '12 at 17:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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