How to Configure
Tiger VNC Server on Linux 7
Applies to:
Oracle Enterprise Linux – Version: 7
Description:
After successful installation of
Oracle Linux 7, I need to configure VNC for remote access.
Solution:
To configure Tiger
VNC server on Oracle Linux 7 follow the simple steps:
To check the required rpm’s:
[root@testora ~]# rpm –qa
|grep tigervnc
Install
tigervnc-server
[root@testora ~]# yum install tigervnc-server –y
To create a user for VNC:
[root@testora ~]# adduser vncuser
[root@testora ~]# passwd vncuser
[root@testora ~]# su - vncuser
[vncuser@testora ~]$ vncpasswd
Password:
Verify:
[vncuser@testora ~]$ exit
[root@testora ~]#
Copy
the following file:
[root@testora
~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@\:1.service
Edit
the copied file.
[root@testora
~]# vi /etc/systemd/system/vncserver@\:1.service
At
the end of the file, you will find the lines like below.
[Unit]
Description=Remote
desktop service (VNC)
After=syslog.target
network.target
[Service]
Type=forking
#
Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh
-c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser
-l <USER> -c
"/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=/bin/sh
-c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
Replace
<USER> with your real user, in my case, i replaced with a user called “vncuser”
[Unit]
Description=Remote
desktop service (VNC)
After=syslog.target
network.target
[Service]
Type=forking
#
Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh
-c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser
-l vncuser -c
"/usr/bin/vncserver %i"
PIDFile=/home/vncuser/.vnc/%H%i.pid
ExecStop=/bin/sh
-c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
Add
TCP Port in Firewall config:
[root@testora
~]# firewall-cmd --permanent --zone=public --add-port=5901/tcp
[root@testora
~]# firewall-cmd --reload
Reload
the systemctl daemon as root
[root@testora
~]# systemctl daemon-reload
Start
the VNC service as root.
[root@testora
~]# systemctl start vncserver@\:1.service
To
check the status of vncserver:
[root@testora
~]# systemctl status vncserver@\:1.service
â
vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded
(/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
Active: active (running) since Tue
2018-12-11 10:58:07 PKT; 6s ago
Process: 9681 ExecStart=/usr/sbin/runuser -l
vncuser -c /usr/bin/vncserver %i (code=exited, status=0/SUCCESS)
Process: 9673 ExecStartPre=/bin/sh -c
/usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited,
status=0/SUCCESS)
Main PID: 9723 (Xvnc)
CGroup:
/system.slice/system-vncserver.slice/vncserver@:1.service
⣠9723 /usr/bin/Xvnc :1 -desktop testora.test.org:1
(vncuser)...
Dec
11 10:58:04 testora.test.org systemd[1]: Starting Remote desktop ser...
Dec
11 10:58:07 testora.test.org systemd[1]: Started Remote desktop serv...
Hint:
Some lines were ellipsized, use -l to show in full.
Enable
it on system startup as root.
[root@testora
~]# systemctl enable vncserver@\:1.service
If
the above procedure did not work, do the following:
[root@testora
~]# rm –rf /tmp/.X*-lock
[root@testora
~]# rm –rf /tmp/.X11-unix/X*
[root@testora
~]# systemctl restart vncserver@\:1.service
OR
do the following:
[root@testora
~]# vncserver
You
will require a password to access your desktops.
Password:
Verify:
xauth: file /root/.Xauthority does not exist
New
'testora.test.org:1 (root)' desktop is testora.test.org:1
Creating
default startup script /root/.vnc/xstartup
Starting
applications specified in /root/.vnc/xstartup
Log
file is /root/.vnc/testora.testt.org:1.log
Now
you can access your Linux server from any client using VNC Viewer.
Your
comments, especially which will help us improve the functionality, will be
greatly appreciatedJ