Installation and use of the VNC remote desktop program in Centos
- 2020-05-15 03:04:40
- OfStack
This article illustrates the installation and use of the VNC remote desktop application in Centos. I will share it with you for your reference as follows:
Take centos 6.5 for example
Install the GNOME desktop environment
yum groupinstall "X Window System" "Desktop"
CentOS install Xfce desktop environment, optional
yum groupinstall Xfce
Install tigervnc
yum install tigervnc-server tigervnc
Set the configuration of remote login to gnome desktop and add the following two lines at the end:
vim /etc/sysconfig/vncservers
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768 -alwaysshared -depth 24"
Modify the remote desktop display profile: change it to the following and save it
vim /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session & #set starting GNOME desktop
#startkde & #kde desktop
#twm & #Text interface
#/usr/bin/startxfce4
#exec /usr/bin/fluxbox
Create a new service, execute for many times, then build multiple services, in order :1 :2 :3, every time you start, you will be prompted to set a password
vncserver
Turn off the specific vncserver command
vncserver -kill :1
vncserver -kill :2
Powered up
chkconfig vncserver on
Firewall setup
When you start the vnc service, you can use the netstat, tunlp command to view the ports used by the vnc service. You can find 5801,5901,6001, etc. Open these ports with the following command:
Restart the firewall:
# netstat � tunlp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 2092/Xvnc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1459/rpcbind
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 2092/Xvnc
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1711/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1557/cupsd
# vim /etc/sysconfig/iptables
-A RH-Firewall-l-INPUT -p tcp -m tcp � dport 5801 -j ACCEPT
-A RH-Firewall-l-INPUT -p tcp -m tcp � dport 5901 -j ACCEPT
-A RH-Firewall-l-INPUT -p tcp -m tcp � dport 6001 -j ACCEPT
# /etc/init.d/iptables restart
Install Windows client:
http://sourceforge.net/projects/tigervnc/files/latest/download
Start the TrigerVNC Viewer
Enter the server IP:01, for example: 192.168.1.10:1
Once connected, enter the password you set every time you start vncserver to connect to the centos desktop
I hope this article has helped you with your CentOS server operations.