vncserver on enterprise linux

In order to have a vnc graphical desktop to your server do the following:

Check if vncserver exists.
If not ... install the package (see other forums)
If installed:

Connect to the unix box as the user that needs to be connected to the linux box via the vncserver.

Step1: init vncfiles for user
Launch the command vncserver.
This will create the required files and config settings in the users home directory.
You will notice the reference of a desktop id, something like :1
Use this referenct to stop the vncserver again by issueing the following command:
vncserver -kill :1

Step2: Enable X for the users remote desktop
Go to the home directory ( simply cd )
Go to the .vnc directory
Edit the file xstartup by uncommenting two lines:
#unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
so that you get
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
Save the file.

Step3: Initialise the vnc password
Launch the command vncpasswd.
Enter two times the password.
This will initialise the password for the user via which you will be connecting

Step 4: Start vncserver again
This step is only required if you want to run vnc not as a service but for restricted time periods.
Issue the command vncserver
Look at the reference the vncserver indicates, eg :1 or something like it.
Make a connection by a vncviewer using the host:reference

Step5: configure the service
Connect as root user
Go to the directory /etc/sysconfig
Modify the file vncserver as root user.
Look at the bottom of the file and duplicate the two lines.
In the pasted lines:
  • uncomment them (remove the # character)
  • in the line VNCSERVERS change the myusername by the user under which you created in steps 1 to 3 the config files
  • In the line VNCSERVERARGS remove the option -localhost
    This would prevent you from connecting from an other host.
(Step 6: What if you need different vnc servers with different users)
This step is optional.
Basically this is very easy.
Just perfom Steps 1 to 3 for each unix user you want to make available via vnc.
So
  • connect as the unix user on the box
  • start vncserver, defaulting the vnc-password of that user
  • stop the vncserver
  • go to directory ~/.vnc
  • uncomment the two lines in the xstartup file
The tricky bit is located in the startup script for the vncserver service. (step 5)
The first line should contain a list of the different displays with the corresponding unix users.
The second line should be repeated for every display that you entered in the list of displays in the first line. For each of the displays specific settings can be done.
The next is an example of two displays with two users:

VNCSERVERS="1:oracle 2:defaultuser"
VNCSERVERARGS[1]="-geometry 1200x1024 -nolisten tcp -nohttpd"
VNCSERVERARGS[2]="-geometry 1200x1024 -nolisten tcp -nohttpd"

Step 7: enable automatic startup of vncserver

Vncserver should be started at the multiuser runlevel, ie runlevel 5.

To enable this perform the following command as root user:
    chkconfig --level 5 vncserver on

To verify the setting in the runleve the following command can be used:
         chkconfig --list | grep vnc

Hope this helps
Yours

No comments: