Thursday, September 17, 2015

Setup VNC server

On Linux  Server as root

Install Software  using  yum repository
yum install vnc-server
yum -y install libXfont
yum install xterm
yum install xorg

Change a File  & Add oracle and Port
vi /etc/sysconfig/vncservers
VNCSERVERS="1:oracle"
VNCSERVERARGS[1]="-geometry 800x600"

Now Change the Password for ONC user
sudo su - oracle
vncpasswd

set password= oracle
As root Start the service

chkconfig --list | grep -i vnc
service vncserver stop
service vncserver start

As root Start the service
maybe stop iptables
service iptables stop

Now Connect to the Box using VNC Client
Download a vnc client such as VNC-Viewer-5.2.3-Windows-32bit  (  yes it is 32 on 64bit box)



Q: How can I run multiple VNC server sessions on the same server at the same time by different users?

Ans:
Open the main config file and add all the users along with any of the id as shown below. So that the user will logon using that ID using vnc client.

# vi /etc/sysconfig/vncservers
VNCSERVERS="2:root 4:deepak "

Once done save the file and assign a vnc pwd to each user manually by logging into their account

NOTE: Make sure you login to the users account for assigning them password or else the vncserver services would not run properly for all the users

# su - deepak

$ vncpasswd
Password: [Give the password for VNC]
Verify: [Retype the password for VNC]
Restart the vncserver services
# service vncserver restart
Shutting down VNC server: 2:root 4:deepak                  [  OK  ]
Starting VNC server: 2:root
New 'server.example.com:2 (root)' desktop is server.example.com:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/server.example.com:2.log

4:deepak
New 'server.example.com:4 (deepak)' desktop is  server.example.com:4

Starting applications specified in /home/deepak/.vnc/xstartup
Log file is /home/deepak/.vnc/server.example.com:4.log

                                                            [  OK  ]
Now you can login to the Linux machine using VNC viewer client using the below syntax

192.168.0.100:2 ==> for user root
192.168.0.100:4 ==> for user deepak

You can also login to the server using your browser. Type the following links for the same

http://server-ip:5802 ==> for user root
http://server-ip:5804 ==> for user deepak

NOTE:
As you can see the port no. when you are trying to access your machine through the browser. It defines the ID of the user which you have assigned in the configuration file.

For example:

2:root - 5802
4:deepak - 5804