Forum / NoMachine for Linux / Can only run desktop as root in container
- This topic has 3 replies, 2 voices, and was last updated 5 years, 7 months ago by Mth.
-
AuthorPosts
-
April 29, 2019 at 07:57 #22143dangmooParticipant
I’ve installed latest free NoMachine server in an LXC container (Ubuntu 16) which resides in Ubuntu 19 KVM VPS. All relevant ports are properly forwarded to the container and things are working fine as root. (I’m using latest Android client to connect).
In the container I have LXDE desktop installed.
The problem is I’m always taken to desktop as root without loading login manager screen first (and I have lightdm installed). That means I’m not able to switch from root and run desktop as normal user.
I’d like to point out that when I installed NoMachine directly on the VPS the login manager showed up normally. It seems this problem only occurs when running in a container.
By the way when I restart NoMachine on the container I can see the following warning (which doesn’t appear when using NoMachine directly on the VPS):
NX> 162 Disabled service: nxserver.
NX> 162 Service: nxnode already disabled.
NX> 162 Disabled service: nxd.
NX> 111 New connections to NoMachine server are enabled.
NX> 161 Enabled service: nxserver.
NX> 162 WARNING: Cannot find X servers running on this machine.
NX> 162 WARNING: A new virtual display will be created on demand.
NX> 161 Enabled service: nxd.
No idea what causing this behavior. Same problem repeated when tested on a Debian 9 container.
I must find a way to switch from root and work as normal user.
I’ve tried to change login manager (and played with some settings found through Google) but nothing helped.
So how can I get desktop loaded as user? Any workaround (dirty as it may be, with or without a login manager) to achieve that?
I can give root access to the container (very basic one, and already snapshoted so safe to go wild..) to anyone who may solve this annoying problem.
Thank you
April 29, 2019 at 13:53 #22159MthContributorHello.
If you are getting warning:
NX> 162 WARNING: Cannot find X servers running on this machine.
It means the desktop environment you installed there is probably not started during container startup.
This means the NoMachine free version can start its own virtual Xserver with desktop environment running. It seems to be happening here, that’s why there is no desktop manager window.
Why the desktop is running as root – there could be two reasons for this.
First, you could be logging in by the nxplayer using root account, then choosing to create desktop on demand when asked by the player.
Second, nxserver could be configured to run the root desktop automaticaly on startup.
This could happen, if first login via nxplayer you ever made was using root account and during this you chose “yes” to create desktop on demand query and then chose to create it automatically.Please check the server.cfg file (by default located in /usr/NX/etc directory) in the container and see if the key CreateDisplay is commented or set to 0.
If it is set to 1, please set it to 0 and do /etc/NX/nxserver –restart, then try to connect using NoMachine player and log in as normal user.
This should allow you to start desktop environment as that user.
/mth
April 29, 2019 at 15:50 #22162dangmooParticipantThanks so much @Mth for your great answer!
The second reason you listed was my case here, and after changing CreateDisplay to 0 (it was 1 indeed) problem solved.
BTW yesterday I found another way (a dirty one) to start desktop as user.
In node.cfg I just specified a bare graphic terminal xterm:
DefaultDesktopCommand “/usr/bin/xterm”
which started by player as root.
Inside xterm terminal I typed the command :
# xhost + username
which basically means ‘allow username to use display owned by root as if it was his own’
then switched to username :
# su – username
then started LXDE desktop as that user:
$ startlxde
Can’t guarantee security of this trick but it worked for me. Only issue with it was no audio. Anyway this is of course unnecessary now after your solution, just leaving it here for general knowledge.
Thanks again 😉
April 30, 2019 at 08:11 #22166MthContributorGlad to be of help.
Just to be exhaustive as possible, there is an additional key in the server.cfg file: DisplayOwner.
If there is only one user that will be logging into the machine or that would need
to have the desktop environment running, it could be specified here, so the
desktop is always created on nxserver service startup, eg:CreateDisplay 1
DisplayOwner “test”providing that there is no native Xserver running would cause on nxserver service
startup to start an virtual desktop for user test.If there is a need for different users to be able to create this desktop on demand, I would
recommend to have CreateDisplay value set to 0.Also for starting terminal session for one user and switching to another by ‘su – username’,
I would really not recommend it, as the NoMachine agent that provides the Xserver
would work as different user, and there is no guarantee that some of the features
that requires user permissions won’t fail./mth
-
AuthorPosts
This topic was marked as solved, you can't post.