Skip to content

Instantly share code, notes, and snippets.

@antoniojxk
Last active July 3, 2018 15:46
Show Gist options
  • Save antoniojxk/b59e2b619c26fbde6ac2718e28c2fa2b to your computer and use it in GitHub Desktop.
Save antoniojxk/b59e2b619c26fbde6ac2718e28c2fa2b to your computer and use it in GitHub Desktop.
how to install VNC on CentOS 6.8

Intall VNC Server and Client on CentOS 6.8

Links

https://wiki.centos.org/HowTos/VNC-Server https://www.server-world.info/en/note?os=CentOS_6&p=x&f=2

  • install vnc-server (tigervnc-server on cenOS 6.8.)
[root@apaternina nfs]# yum install tigervnc-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.uniminuto.edu
 * extras: centos.uniminuto.edu
 * updates: centos.uniminuto.edu
Package tigervnc-server-1.1.0-18.el6.x86_64 already installed and latest version
Nothing to do
  • install vnc client
[root@apaternina nfs]# yum install vnc
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.uniminuto.edu
 * extras: centos.uniminuto.edu
 * updates: centos.uniminuto.edu
Package tigervnc-1.1.0-18.el6.x86_64 already installed and latest version
Nothing to do
  • Create the VNC users accounts
$ su -
# useradd vnc-user
  • Edit the server configuration.
vi /etc/sysconfig/vncservers 

VNCSERVERS="1:vnc-user"
VNCSERVERARGS[1]="-geometry 640x480"
  • Set your users' VNC passwords.
[root@apaternina nfs]# su vnc-user
[vnc-user@apaternina nfs]$ vncpasswd
Password:
Verify:
[vnc-user@apaternina nfs]$ cd /home/vnc-user/.vnc/
[vnc-user@apaternina .vnc]$ ls
passwd
[vnc-user@apaternina .vnc]$ exit
exit
[root@apaternina nfs]# 
  • Confirm that the vncserver will start and stop cleanly.
[root@apaternina ~]# service vncserver start
Starting VNC server: 1:vnc-user xauth: (stdin):1:  bad display name "apaternina:1" in "add" command

New 'apaternina:1 (vnc-user)' desktop is apaternina:1

Starting applications specified in /home/vnc-user/.vnc/xstartup
Log file is /home/vnc-user/.vnc/apaternina:1.log

                                                           [  OK  ]
[root@apaternina ~]# service vncserver stop
Shutting down VNC server: 1:vnc-user                       [  OK  ]
[root@apaternina ~]# chkconfig vncserver on
  • Amend the iptables.
[root@apaternina ~]# vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
  • make changes to iptables persistent
[root@apaternina apaternina]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
  • restart iptables
[root@apaternina ~]# service iptables restart

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
  • Start the VNC service.
[root@apaternina ~]# service vncserver start
Starting VNC server: 1:vnc-user xauth: (stdin):1:  bad display name "apaternina:1" in "add" command

New 'apaternina:1 (vnc-user)' desktop is apaternina:1

Starting applications specified in /home/vnc-user/.vnc/xstartup
Log file is /home/vnc-user/.vnc/apaternina:1.log

                                                           [  OK  ]
  • Test each VNC user.
vncviewer 192.168.56.100:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment