Centos – StartX Fatal Server Error After Opening VNC Session

centosgnome

I've configured vncserver on my CentOS5 system and it now accepts remote VNC connections. I want the user to automatically be presented with the Gnome desktop upon successful VNC connection. In testing this, I tried executing startx after establishing a connection and receive the following:

Fatal server error:
PAM authentication failed, cannot start X server.
Perhaps you do not have console ownership?

How do I rectify this issue?

Best Answer

You're still not very clear on whether you are running Gnome on the monitor plugged into the computer and want to access that over VNC, or if you want to run Gnome on the virtual desktop that vncserver provides.

If you want the virtual desktop, edit the ~/.vnc/xstartup file and uncomment the two lines it tells you to uncomment (remove the # from in front of the command) in order to get a "normal desktop". If gnome isn't set up as the system's default desktop, then you'll need to change the exec /etc/X11/xinit/xinitrc command to exec /usr/bin/gnome-session. Note that if your user is already running a gnome session (say, on the monitor) then you will be unable to start another gnome session. (According to this thread.)

If you want the desktop you see on the monitor to be available over vnc, then you'll need to configure the X "vnc" module included in the vnc-server centos package. There are instructions on doing so here. Note that installing it as an X module means that the VNC server is always on whenever X is running (whether a user is logged in or not) and that any user who has the password to the VNC server can connect to the computer no matter who is logged in to the computer. The alternative is to install x11vnc which uses screen grabbing to serve the display but only when you specifically run the x11vnc server. (Centos5 instructions here.)

Finally, if you really do mean that you want vncserver to serve a virtual desktop AND you want it to not start Gnome until someone connects, then the instructions also cover that here.

Whichever way you've chosen, be sure you've read the security section on that centos instructions page.