Configuring VNC Server Access on a Redhat Linux
Most of the time as a system administrator you are managing your servers over the network. It is very rare that you will need to have a physical access to any of your managed servers. In most cases all you need is to SSH remotely to do your administration tasks. In this article we will configure a GUI alternative to a remote access to your RHEL server, which is VNC. VNC allows you to open a remote GUI session to your server and thus providing you with a full graphical interface accessible from any remote location.
2. Installation of VNC server
In order to enable an access to our Redhat Linux system using VNC we first need to install it. Make sure that you have your repository enabled and execute the command:
# yum install tigervnc-server
The above command will install the VNC server on your system.
3. Setting up VNC session
At this point we should have VNC server installed on our system and thus we are ready to setup sessions. In VNC you can define a separate access session for each particular user. For this we will use VNC configuration file: /etc/sysconfig/vncservers
To configure VNC for a user "lubos" /etc/sysconfig/vncservers file insert the following lines:
VNCSERVERARGS="-geometry 800x600 -nolisten tcp -localhost"
The above will configure VNC session 2 for a user lubos with specified geometry windows size. -nolisten and -localhost are added as a security precaution. You can omit -nolisten and -localhost and connect to VNC directly. In that case you will need to open a VNC port on your firewall. It is recommended to use -nolisten and -localhost option and thus allow clients to connect only via existing secure ssh port 22 using the SSH tunnel.
Before you start the VNC service, first you will need to create a VNC password for each user session you have configured in /etc/sysconfig/vncservers. To do that su to each user and execute:
[root@rhel ~]# su lubos
[lubos@rhel root]$ vncpasswd
At this point you will be able to start the VNC service with the command:
# service vncserver start
4. Connecting to VNC server
If you allowed your clients to connect to your VNC server without the secure SSH tunnel, you first need to make sure that your firewall allows this connection. Then simply connect to your VNC using:
$ vncviewer rhel.server:2
Connected to RFB server, using protocol version 3.8
Performing standard VNC authentication
where rhel.server is a hostname or IP address of your server and number 2 is a session number you have configured for your user. Once you enter a correct password your session will start.
4.1. Connecting to VNC server via SSH tunel
It is recommend to connect to VNC via ssh tunnel. This can be easily done using vncviewer -via option with will automatically create an ssh tunnel for you:
First, you will be prompted for a password:
Once you enter a correct password for your VNC user your VNC session will start:
VNC is a great tool for remote connection to you server when GUI interface is needed. It also has an advantage of running task remotely and keep them alive even once your network connection to a remote VNC was disconnected. This is a quite useful if you run some important GUI updates, which may take several hours and you do not want to kill this update simply by loosing a network connection.