VNC server is used to connect and control desktop environment of the server from remote clients. VNC viewer is used on remote computer to connect the server .
In the article we can learn about how to install vnc server on centos 7 . we can use the default packages provided in the centos yum repository.

How to Setup X11VNC Server on Ubuntu & LinuxMint
Install vnc server on centos 7

Let’s start. If you don’t have desktop environment ( X windows ), issue the below commands one by one to install. It will take few minutes to install packages.

[root@hackthesec ~]# yum check-update
hackthesec ~]# yum groupinstall "X Window System"
hackthesec ~]# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
[root@hackthesec ~]# unlink /etc/systemd/system/
[root@hackthesec ~]# ln -sf /lib/systemd/system/ /etc/systemd/system/
[root@hackthesec ~]# reboot

After reboot, you will get Centos 7 desktop .
Now start installing VNC packages.
Step 1 : Issue the below command to install VNC package.

[root@hackthesec  ~]# yum install tigervnc-server -y
Step 2 : Create a file vncserver@:1.service in /etc/systemd/system/ directory by copying example config file /lib/systemd/system/vncserver@.service

[root@hackthesec ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
Step 3 : Now open /etc/systemd/system/vncserver@:1.service file and replacewith your username .
Find these lines ..

ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"PIDFile=/home/<USER>/.vnc/
Replace ( Considering username as john )

ExecStart=/sbin/runuser -l john -c "/usr/bin/vncserver %i"

If you are creating for root user .

ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"

Step 4 : Reload systemd for changes.

[root@krizna ~]# systemctl daemon-reload
Step 5 : Create VNC password for the user .

[root@hackthesec ~]# vncpasswd
Step 6 : Enable and start the service using the below commands.
Enable service at startup ( Permanent ).

[root@hackthesec ~]# systemctl enable vncserver@:1.service
Start the service .

[root@hackthesec ~]# systemctl start vncserver@:1.service
Step 7 : Allow VNC service in firewall.

[root@hackthesec ~]# firewall-cmd --permanent --add-service vnc-server
hackthesec ~]# systemctl restart firewalld.service

Now you can able to connect VNC server using IP and Port ( Eg : )

You can use VNC client like Tightvnc viewer and Realvnc viewer to connect Server.
For additional users create files with different ports ( Refer Step 2 )vncserver@:2.service by copying example config file and continue the steps 3,4,5 and 6 by replacing service name. Please make sure you logged in as that particular user for creating vnc password ( Step 5 ).

Additional Commands :

 To stop VNC service .
[root@hackthesec ~]# systemctl stop vncserver@:1.service
 To disable VNC service from startup ( permanent ).

[root@hackthesec ~]# systemctl disable vncserver@:1.service
To stop firewall ( For troubleshooting ).

[root@krizna ~]# systemctl stop firewalld.service

Hack The Security
Hack The Security Twitter
Hack The Security Facebook

About Author:

I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Newer Post
Older Post


Post a Comment