1、确认自己linux系统是否安装VNC
[root@serv1 ~]# rpm -q vnc-server
vnc-server-4.1.2-14.el5_6.6
出现上面的信息说明已经安装了vnc服务。
2、启动vnc服务
[root@serv1 ~]# vncserver :1
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /root/.Xauthority
New 'serv1.ganjh.com:1 (root)' desktop is serv1.ganjh.com:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/serv1.ganjh.com:1.log
其中提示你输入密码,这个密码就是客户端vnc登陆linux的密码。
3、查看linux是否开放了5801,5901端口
[root@serv1 ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
[root@serv1 ~]# iptables -I INPUT -p tcp --dport 5801 -j ACCEPT
4、使用VNC Viewer软件登陆测试,操作流程如下启动VNC Viewer软件 -->
Server输入“172.25.6.249:1” --> 点击“OK” -->
Password输入登陆密码 --> 点击“OK”登陆到X-Window图形桌面环境 --> 测试成功
5、上面的方式只是配置了字符界面,如果要看到gnome界面,那么还要修改Linux配置文件
vi /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" &
twm &
6、重新启动vnc server
[root@serv1 ~]# vncserver -kill :1
Killing Xvnc process ID 4046
[root@serv1 ~]# vncserver :1
New 'serv1.ganjh.com:1 (root)' desktop is serv1.ganjh.com:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/serv1.ganjh.com:1.log