- 查看是否安装了VNCServer
rpm -qa | grep vnc
如果没有安装vnc,执行
yum install -y tigervnc-server
- 配置开机自启动
chkconfig --level 345 vncserver on
- 配置VNC用户
在root用用户下执行,
vi /etc/sysconfig/vncserver
内容如下
# The VNCSERVERS variable is a list of display:user pairs.
# Uncomment the lines below to start a VNC server on display :2
# as my ‘myusername’ (adjust this to your own). You will also
# need to set a VNC password; run ‘man vncpasswd’ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see this URL:
# https://access.redhat.com/knowledge/solutions/7027
# Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.
# Use “-localhost” to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the “-via” option in the
# `man vncviewer’ manual page.
# VNCSERVERS=”2:myusername”
# VNCSERVERARGS[2]=”-geometry 800x600 -nolisten tcp -localhost”
在文件末尾添加
VNCSERVERS=”1:root”
VNCSERVERARGS[1]=”-geometry 1366x768”
如果需要多个用户,在VNCSERVERS后面,用空格进行分割。如
VNCSERVERS=”1:root 2:oracle”,相应的,需要添加VNCSERVERARGS[2]=”-geometry 1366x768” 1366x768值得是vnc屏幕的分辨率
添加VNC用户的密码。如果配置了root的vnc登陆,在root用户下,执行
vncserver
输入vnc的密码,vnc用户的密码,这里指的是vnc用户登录的密码,如果配置了多个vnc用户,那么需要分别在对应的用户下面,执行vncserver命令,指定vnc用户的密码.配置VNC用户登录的桌面环境
执行完vncserver以后,需要配置vnc用户登陆的桌面环境,
vi /root/.vnc/xstartup
在文件末尾,添加 gnome-session & ,指定登陆桌面环境为gnome配置防火墙
执行
iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
,如果配置了多个用户,那么分别执行iptables -I INPUT -p tcp --dport 5902 -j ACCEPT
,5901,5902 分别对应1:root,2:oracle…….。 保存防火墙service iptables save
- 启动vncserver
service vncserver restar