vnc-server
How to Setup VNC Server (Linux Remote Desktop Access) on CentOS/RHEL and Fedora
Installing GNOME GUI on CentOS 5
How to install a GUI on CentOS
Step 1: Install Required Packages
Most of Linux servers doesn’t have desktop installed on their system. So make sure you have installed else use following command to install it.
For CentOS/RHEL 6: # yum groupinstall "Desktop"
#yum install xterm
For CentOS/RHEL 5: # yum groupinstall "GNOME Desktop Environment"
Now install few required packages for vnc-server
# yum install pixman pixman-devel libXfont
Step 2: Install VNC Server
After installing required packages, lets install vnc-server in your system. vnc-server is available under default yum repositories.
# yum install vnc-server
On CentOS/RHEL 6, you will see that tigervnc-server package will be installed.
Step 3: Create User for VNC
Lets’ create few users for connecting through vnc. You can also use existing system users by connecting through vnc, In that case we only need to set vncpasswd for that account.
# useradd user1 # passwd user1 # useradd user2 # passwd user2
Now set the vnc password for all accounts need to connect through vnc.
# su - user1 $ vncpasswd $ exit # su - user2 $ vncpasswd $ exit
Step 4: Configure VNC Server for Users
Now edit /etc/sysconfig/vncservers configuration file and add the following to the end of the file.
#vim /etc/sysconfig/vncservers
VNCSERVERS="1:user1 2:user2" VNCSERVERARGS[1]="-geometry 800x600" VNCSERVERARGS[2]="-geometry 1024x768"
Where VNCSERVERS is the list of users need to connect, VNCSERVERARGS defined the screen size. Like user1 have a 800×600 screen, and user2 have 1024×768 screen size on his client.
Now start vnc-server service using following command and check the output
# service vncserver start Starting VNC server: 1:user1 xauth: creating new authority file /home/user1/.Xauthority New 'svr1.tecadmin.net:1 (user1)' desktop is svr1.tecadmin.net:1 Creating default startup script /home/user1/.vnc/xstartup Starting applications specified in /home/user1/.vnc/xstartup Log file is /home/user1/.vnc/svr1.tecadmin.net:1.log 2:user2 xauth: creating new authority file /home/user2/.Xauthority New 'svr1.tecadmin.net:2 (user2)' desktop is svr1.tecadmin.net:2 Creating default startup script /home/user2/.vnc/xstartup Starting applications specified in /home/user2/.vnc/xstartup Log file is /home/user2/.vnc/svr1.tecadmin.net:2.log [ OK ]
As per above output, you can see that user1 desktop is available on :1 and user2 desktop is available on :2. We will use :1 to connect to user1 and :2 to connect to user2.
----------
[cent@dlp ~]$ vi /home/cent/.vnc/xstartup
#twm & # end line: comment out
exec gnome-session & # use Ghome
---------------------#######################---------------------------------------------
For Windows view
Configure the VNC Desktop Environment and Password,” when you edit the /home/username/.vnc/xstartup file, you need to uncomment two lines near the top of the file so that it reads:
# Uncomment the following two lines for normal desktop: unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc
After uncommenting those two lines, go to the bottom of the file and comment out the twm & line, then add a line that tells VNC to start GNOME desktop. The last two lines should read:
# twm & startx &
----------------------XXXXXXXXXXXXXXXXXXXXXXXX-------------------------------------------------
# run with diplay number '1', screen resolution '800x600', color depth '24'
[cent@dlp ~]$ vncserver :1 -geometry 800x600 -depth 24
Pls change graphical valu
#vi /etc/inittab
Line:18 # id:5:initdefault: [change 3 write 5]
Reboot PC
------------------------------------------------------------------------------------------
Step 5: Connect VNC Server using VNC Viewer
To access from remote Linux system use following command.
# vncviewer 192.168.1.11:1
To access remote desktop on vnc-server from windows system, you must have vnc-viewer installed on your system. There are various vnc viewer available to use. Download any one and install on your system, for example:
TightVNC: http://www.tightvnc.com/download.php
RealVNC: https://www.realvnc.com/download/vnc/
TigerVNC: http://sourceforge.net/projects/tigervnc/files/tigervnc/
After installing vnc viewer connect to your system, In below example we are connected to user1 (:1).
Now enter vnc password of account assigned with vncpasswd command.
You are connected to x windows system of your Linux machine.
##########################################################################################################
CentOS ---6/7 64 bit vnc Configure
service iptables stop
service ip6tables stop
chkconfig iptables off
chkconfig ip6tables off
For GNOME:
# yum groupinstall "General Purpose Desktop" "Desktop Platform"
For KDE:
# yum groupinstall "KDE Desktop"
# yum groupinstall Desktop
# yum install xorg-x11-fonts-Type1
Install VNC server
# yum -y install vnc-server
Install Tigervnc-Server
# yum install tigervnc-server
# yum install xorg-x11-fonts-Type1
VNC Server/Client:
====================
=> Graphically remote Login
=> Port 5900
=> packages: vnc, tigervnc-server (server),
[root@ns1 ~]# yum install tigervnc-server* -y
[root@ns1 ~]#
Step 02: VNC password Setup
----------------------------
[root@ns1 ~]# vncpasswd
Password: *******
Verify: ******
[root@localhost ~]# useradd u1 # Create a User "u1
passwd u1
[root@localhost ~]# su - u1 # Switch to User "u1"
vncpasswd # Set Password to login VNC Server
Password:
Verify:
[root]$ exit
Step 03: VNC user and screen resulation setup
----------------------------------------------
[root@ns1 ~]# vim /etc/sysconfig/vncservers
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768"
-----OR------
VNCSERVERS="1:user1 2:user2"
VNCSERVERARGS[1]="-geometry 800x600" VNCSERVERARGS[2]="-geometry 1024x768"
VNCSERVERS="1:root 2:u1"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"
Step 04: service restart
----------------------------
[root@ns1 ~]# service vncserver restart
[root@ns1 ~]# chkconfig vncserver on
Step 05: user session configure
-------------------------------
[root@ns1 ~]# vim /root/.vnc/xstartup
29 #twm &
30 exec gnome-session &
[root@ns1 ~]# service vncserver reload
VNC Client Configure (Linux)
------------------------------
[root@ns1 ~]# yum install tigervnc* -y
Application => Internet => tigervnc
VNC Serve IP: 192.168.11.x:1
passwd: *******
------------------------------------------
Pls change graphical valu----Linux
vi /etc/inittab
Line:18 id:5:initdefault: [change 3 write 5]
Note [ if not login pls allow] :
VNCSERVERS="1:user"
VNCSERVERARGS[1]="-geometry 1280x768"
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 1280x768"
These are my firewall entries allowing VNC on CentOS 6.5:
---------------------------------------------------------------------
# vi /etc/shorewall/rules
##VNC
ACCEPT net $FW tcp 5800
ACCEPT net $FW tcp 5900
ACCEPT net $FW tcp 5901
ACCEPT net $FW tcp 6000
# service shorewall restart
[root@server ~]# vi /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 -m multiport --dports 5901:5902,6001:6002 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# service iptables restart
-------------------------------------------------------------------------------------------
LOG
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/mail:1.log
# tail -f /root/.vnc/mail:1.log