how to open X windows after su'ing to another user?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to open X windows after su'ing to another user?
I have some users who have some problems that are specific to their machine. In order to test, I have to open a GUI on their machine as their user, but if I ssh as root (with -X option) to their machine so I can su to them, I can no longer launch Xwindows... I get the message:
X11 connection rejected because of wrong authentication.
Connection lost to X server `localhost:10.0'
I thought that meant I just had to set the DISPLAY env var, but that either isn't the problem, or I don't know the value to set. I was trying my_machine:0.0 as the DISPLAY var - but that gives a new message about Cannot connect to X server on my_machine:0.0" - maybe 0.0 is not the right number?
For the record, I can open X windows after sshing, just not after sshing then suing.
Did you try the -Y option instead of the -X one? Since you're "root," the -X restrictions might not apply, but after the su you're no longer "root," eh?
Just a guess - I never use ssh on my one-person laptop.
Did you try the -Y option instead of the -X one? Since you're "root," the -X restrictions might not apply, but after the su you're no longer "root," eh?
Just a guess - I never use ssh on my one-person laptop.
The default display for X-forwarding, as per sshd_config is :10.0, so that part of the error message is correct.
I'm puzzled as to why you don't/can't ssh as the user, rather than as root and then su'ing. I'm thinking that this may be the issue, since from the user's machine's standpoint, the :10.0 display is 'owned' by root, not by the user, thus the authentication issue.
These are just thoughts, and by no means an attempt at expertise....
Opened a terminal window in my current X session.
Did a su - to start a "root" login shell
Did a su -m Peter to go back to my user environment (without a password prompt)
Did a startx -- :1 to open a second X server for the user login.
Checked that I could switch between the :0 and :1 sessions with <ctrl><alt><F7> and <ctrl><alt><F8>
Logged out of the :1 session and cleaned up.
All that worked.
So, try starting a "root" X-server (which you said worked), do your su to the user, and then a startx -- :1 to start a second X-server for the user. (Perhaps you'll need a startx -- 10:1 per the comments above.)
I use ssh with the -Y option to log in as a normal user.
To use a GUI program with root privileges, I do 'kdesu <program name>'.
This works fine if you have kde installed as kdesu takes care of all the display stuff.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.