We will be setting up VNC for a new user, using the account name of john as an example.
1. Create the VNC user accounts as root:
$ su - # useradd john # passwd john
2. Edit the server configuration file /etc/sysconfig/vncservers, and append john on VNCSERVERS line and set VNCSERVERARGS.
# vi /etc/sysconfig/vncservers VNCSERVERS="1:aa 2:john" VNCSERVERARGS[1]="-geometry 640x480" VNCSERVERARGS[2]="-geometry 640x480"
Account john will have a 640 by 480 screen resolution.
3. Set users’ VNC passwords. Switch user to the account for each user, and as noted below, run vncpasswd command. This will create the ~/.vnc directory for that userid:
# su - john $ vncpasswd
$ cd .vnc $ ls passwd $ exit #
4. Confirm that the vncserver will start and stop cleanly. Create the xstartup scripts by starting and stopping the vncserver as root.
# service vncserver start # service vncserver stop # chkconfig vncserver on
5. Create xstartup scripts. Login to each user and edit the xstartup script.
$ cd .vnc $ ls mymachine.localnet:1.log passwd xstartup
Edit ~/.vnc/xstartup for john as below:
#!/bin/sh # Add the following line to ensure you always have an xterm available. ( while true ; do xterm ; done ) & # Uncomment the following two lines for normal desktop: unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & twm &
6. Start the vncserver as root.
# service vncserver start
7. Test each VNC user with a vnc client, replace [ip_of_vnc_server] with ip address of vnc server. For account john:
# vncviewer [ip_of_vnc_server]:2