Setting up VNCServer on Linux CentOS 6.2
CentOS does have a built in VNC server I found called Remote Desktop (not to be confused with Windows Remote Desktop). I managed to get that turned on and working but the performance of it seemed slow.
I then tried RealVNC but had troubles getting it started at boot. I found these instructions and used them to form my set of instructions.
These instructions will help you install VNCServer (TigerVNC), open ports on the firewall and start VNCServer at boot.
A few things about VNCServer on Linux. It doesn’t work quite the same as on Windows. You get connected to a new instance of X Windows for each user.
If you log off the user it tends to kill the session and it won’t work again unless vncserver is restarted or you reboot.
This doesn’t connect you to the “console” session, the session that’s present at the keyboard and monitor.
I didn’t take time to figure out the best way to do that.
These instructions assume you know how to edit text files using vi.
If no here is a good cheat sheet: http://www.lagmonster.org/docs/vi.html
Install VNCServer as root: yum install vnc-server
Login and create vnc password: vncpasswd (logged in as vnc user not root)
Edit vnc server configuration: vi /etc/sysconfig/vncservers
Remove the # sign from the VNCSERVERS AND VNCSERVERARGS
Add a port for each user you need (2:username means port 2)
Remove -localhost or you won’t be able to connect to the server.
That is for encrypted connections through ssh.
So mine looks like:
Start VNC Server manually /sbin/service vncserver start
Add VNC ports to firewall (iptables)
Add these under the :OUTPUT ACCEPT [0:0]
-A INPUT -m tcp -p tcp –dport 5900 -j ACCEPT
-A INPUT -m tcp -p tcp –dport 5800 -j ACCEPT
-A INPUT -m tcp -p tcp –dport 6000 -j ACCEPT
-A INPUT -m tcp -p tcp –dport 5901 -j ACCEPT
-A INPUT -m tcp -p tcp –dport 5801 -j ACCEPT
-A INPUT -m tcp -p tcp –dport 6001 -j ACCEPT
-A INPUT -m tcp -p tcp –dport 5902 -j ACCEPT
-A INPUT -m tcp -p tcp –dport 5802 -j ACCEPT
-A INPUT -m tcp -p tcp –dport 6002 -j ACCEPT
(Note: you don’t have to put in all of these sets if you only are connecting one user.)
(Also if you only want to allow the connections from one interface and not all you can add -i eth0 after the second tcp.
This would allow connections to only interface eth0)
Restart iptables: service iptables restart
Test connecting from another VNC client with
Set VNCServer to start at boot: /sbin/chkconfig vncserver on
To see if the vncserver is running: netstat -tulpan | grep vnc