Setting Up VNC Server On Oracle Enterprise Linux 6.7
VNC stands for Virtual Network Computing, which allows us to access GUI of our server remotely. Though we DBA does our every task by connecting to our server via SSH-TTY tunnel. However in some cases we need to have GUI access of the server to perform certain tasks, which needs a Display. We’ll just need to have VNC Client Application to access it. So in this post we’ll see how to setup VNC Server in easiest way on your Oracle Enterprise Linux 6 / RedHat Enterprise Linux 6, however this is demonstrated on Oracle Enterprise Linux 6.7.
To setup VNC Server, we need to install Packages of VNC Server. We’ll use tigervnc and there are several ways to install these packages, however using yum is always best and preferable because yum itself checks if all dependency packages are present or not and installs missing dependency packages as well.
Note : To perform any administrative operations we’ll always need to switch to root user or optionally sudo can be used.
1. Check if Tiger VNC is installed on your system.
Run below commands to check if VNC Server is installed or not.
[root@dbnode1 ~]# yum list | grep tigervnc
or
[root@dbnode1 ~]# rpm -qa | grep tigervnc
If above commands returns nothing, it means there is no VNC Server installed on the server. So we can proceed with installation now.
2. Before installing check info about Tiger VNC on yum repository.
[root@dbnode1 /]# yum info tigervnc-server Loaded plugins: refresh-packagekit, security, ulninfo Available Packages Name : tigervnc-server Arch : x86_64 Version : 1.1.0 Release : 24.el6 Size : 1.0 M Repo : public_ol6_latest Summary : A TigerVNC server URL : http://www.tigervnc.com License : GPLv2+ Description : The VNC system allows you to access the same desktop from a wide : variety of platforms. This package is a TigerVNC server, allowing : others to access the desktop on your machine.
Above are the details of Architecture, Name, Release, Size, License and more.
3. Install Tiger VNC using yum.
[root@dbnode1 /]# yum install tigervnc-server Loaded plugins: refresh-packagekit, security, ulninfo Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package tigervnc-server.x86_64 0:1.1.0-24.el6 will be installed --> Processing Dependency: libxshmfence.so.1()(64bit) for package: tigervnc-server-1.1.0-24.el6.x86_64 --> Running transaction check ---> Package libxshmfence.x86_64 0:1.2-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Installing: tigervnc-server x86_64 1.1.0-24.el6 public_ol6_latest 1.0 M Installing for dependencies: libxshmfence x86_64 1.2-1.el6 public_ol6_latest 5.6 k Transaction Summary ============================================================================================================ Install 2 Package(s) Total download size: 1.0 M Installed size: 2.6 M Is this ok [y/N]:
Once yum completes with searching installation package on Yum repository, yum prompts for Yes / No option, type Y for yes selection.
Is this ok [y/N]: y Downloading Packages: (1/2): libxshmfence-1.2-1.el6.x86_64.rpm | 5.6 kB 00:00 (2/2): tigervnc-server-1.1.0-24.el6.x86_64.rpm | 1.0 MB 00:00 -------------------------------------------------------------------------------------------------------------- Total 670 kB/s | 1.0 MB 00:01 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : libxshmfence-1.2-1.el6.x86_64 1/2 Installing : tigervnc-server-1.1.0-24.el6.x86_64 2/2 Verifying : libxshmfence-1.2-1.el6.x86_64 1/2 Verifying : tigervnc-server-1.1.0-24.el6.x86_64 2/2 Installed: tigervnc-server.x86_64 0:1.1.0-24.el6 Dependency Installed: libxshmfence.x86_64 0:1.2-1.el6 Complete!
This Complete! message means, Installation of Tiger VNC Server was successful on your Linux machine. Once it is installed we’re good to setup VNC User.
4. Now, Edit VNC Server Configuration file and add below entries.
[root@dbnode1 /]# vi /etc/sysconfig/vncservers # The VNCSERVERS variable is a list of display:user pairs. # # Uncomment the lines below to start a VNC server on display :2 # as my 'myusername' (adjust this to your own). You will also # need to set a VNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUN THIS SERVICE if your local area network is # untrusted! For a secure way of using VNC, see this URL: # https://access.redhat.com/knowledge/solutions/7027 # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP. # Use "-localhost" to prevent remote VNC clients connecting except when # doing so through a secure tunnel. See the "-via" option in the # `man vncviewer' manual page. VNCSERVERS="1:root 2:oracle" VNCSERVERARGS[1]="-geometry 1360x768" VNCSERVERARGS[2]="-geometry 1360x768"
And then save and exit.
[ESC] > :wq > Enter (to save and exit)
5. VNC Service by default runs on 5900 to 6000 port range. Now make sure your firewall allows inbound connection for VNC Service on given ports.
- Edit iptables file located in /etc/sysconfig and add below lines (after the entry of port 22) to open 5901 and 5902 port on firewall.
[root@dbnode1 /]# vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5902 -j ACCEPT
And then save and exit.
[ESC] > :wq > Enter (to save and exit)
Your iptables should look like,
[root@dbnode1 /]# cat /etc/sysconfig/iptables # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5902 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 1158 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
6. Once we’re done with vnc and iptables configuration, then we have to set vnc password for both users, root and oracle.
- To do this we will issue following command.
For root
[root@dbnode1 /]# vncpasswd Password: [enter password] Verify: [verify password]
For oracle
[root@dbnode1 /]# su - oracle [oracle@dbnode1 ~]$ vncpasswd Password: [enter password] Verify: [verify password]
7. Now, restart both the linux services vnc and iptables.
VNC
[root@dbnode1 /]# service vncserver restart Shutting down VNC server: [ OK ] Starting VNC server: 1:root xauth: creating new authority file /root/.Xauthority xauth: (stdin):1: bad display name "dbnode1.demunix.com:1" in "add" command New 'dbnode1.demunix.com:1 (root)' desktop is dbnode1.demunix.com:1 Creating default startup script /root/.vnc/xstartup Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/dbnode1.demunix.com:1.log 2:oracle ORACLE PROFILE LOADED xauth: creating new authority file /home/oracle/.Xauthority xauth: (stdin):1: bad display name "dbnode1.demunix.com:2" in "add" command New 'dbnode1.demunix.com:2 (oracle)' desktop is dbnode1.demunix.com:2 Creating default startup script /home/oracle/.vnc/xstartup Starting applications specified in /home/oracle/.vnc/xstartup Log file is /home/oracle/.vnc/dbnode1.demunix.com:2.log [ OK ]
And iptables
[root@dbnode1 /]# service iptables restart iptables: Setting chains to policy ACCEPT: nat mangle filte [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules: [ OK ]
Cheers !! We’re done setting up everything now. Let’s try to connect via VNC client now.
This is the screenshot from VNC Viewer client for Google Chrome.
Let’s enter in hostname:display number format. Here dbnode1.demunix.com is hostname and we’re trying to connect to display 1 which is configured for root user in /etc/sysconfig/vncserver file.
You maybe prompted with Unencrypted Connection warning. check the checkbox saying Do not warn me for hostname again to avoid future warnings and click on connect.
Enter VNC password set for root user.
And here is the Remote Display access of the server on TigerVNC Server.
Here we go, we’ve successfully configured TigerVNC Server on Oracle Enterprise Linux 6.7.
Listen to Podcast of this post, Available on :
Peace 🙂
Great Work!!