Running multiple VNC server sessions for different users in Linux

In my another article I have shared step by step guide to configure VNC server using Red Hat Linux 7.

 

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

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 config file and assign a vnc password 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