参考原文
关闭vncserver参考
VNC是一款优秀的远程控制工具软件,由著名的AT&T的欧洲研究实验室开发的。VNC是在基于UNIX和Linux操作系统的免费的开放源码软件,远程控制能力强大,高效实用,香港空间,其性能可以和Windows和MAC中的任何远程控制软件媲美。
首先是安装了 CentOS 6.0 的 64 位版。本文讲解的是一种方法。VNC 配置网上搜了有很多,但是貌似写的都不够基础,这里仔细按步骤记录一下。
一、安装 VNC
首先检查一下本机是否安装了 VNC,默认情况下,CentOS 6.0 是没有安装的。
检查是否安装,输入:
[root@localhost ~]# rpm -q vnc vnc-server
得到:
package vnc is not installedpackage vnc-server is not installed
提示没有安装,那么就开始安装,输入:
[root@localhost ~]# yum install vnc vnc-server
注:如果是 Ubuntu 则输入:
[root@localhost ~]# apt-get install vnc vnc-server
在一串指令提示后,会让你确认一些选项,输入两次 “Y” 并确认,稍作等待,提示 “Complete!” 即完成安装。
二、设置 VNC 密码
启动 VNC,输入:(在某用户下输入则登陆用户就是它,如果su imiss切换到imiss用户,输入vncserver则启动的是另一个桌面,同样要设置密码,以后在该账户下启动的vncserver登陆就需要在此用户下设置的密码了。)
[root@localhost ~]# vncserver
此时会提示你输入密码,因为是第一次配置。重复输入两次即可。
修改密码:
[root@localhost ~]$ vncpasswd
Password:
Verify:
三、配置桌面类型
设置一下远程桌面使用那个类型的桌面,虚拟主机,分辨率多少等等。输入:
[root@localhost ~]# vi ~/.vnc/xstartup
得到:
#!/bin/shvncconfig -iconic &unset SESSION_MANAGERunset DBUS_SESSION_BUS_ADDRESSOS=`uname -s`if[ $OS = ‘Linux’]; thencase”$WINDOWMANAGER”in*gnome*)if[ -e /etc/SuSE-release ]; thenPATH=$PATH:/opt/gnome/binexport PATHfi;;esacfiif[ -x /etc/X11/xinit/xinitrc ]; thenexec /etc/X11/xinit/xinitrcfiif[ -f /etc/X11/xinit/xinitrc ]; thenexec sh /etc/X11/xinit/xinitrcfi[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresourcesxsetroot -solid greyxterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop”&twm &
一般情况下,我们使用的 Linux 桌面都是 “Gnome” 桌面,故配置成这个桌面比较习惯。
按 “i” 键进入编辑状态,主要修改最后两行。改为:
# xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &# twm &gnome-session &
一看便知,将配置文件的最后两行注释掉,并且加入了一行代码,表明使用的是 “Gnome” 桌面。
输入完毕,按 “ESC” 键退出编辑状态,再输入:
:wq
”w” 表示写,即保存配置,”q” 表示退出。
四、配置登录帐号、桌面分辨率、连接方式
输入:
[root@localhost ~]# vi /etc/sysconfig/vncservers
出现如下提示:
# 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:# # 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 800×600 -nolisten tcp -localhost”
重点编辑最后两行,将这两行注释去掉,得到:
VNCSERVERS=”1:root”VNCSERVERARGS[1]=”-geometry 1024×768″
这里是只有一个帐号登录,设置分辨率为1024*768,如果你有多个帐号,则按照下面格式配置。
VNCSERVERS=”1:user1 2:user2 3:user3″VNCSERVERARGS[1]=”-geometry 1024×768″VNCSERVERARGS[2]=”-geometry 1024×768″VNCSERVERARGS[3]=”-geometry 800×600 -depth 24 -nolisten tcp -nohttpd -localhost”巨龟千岁,却也平淡无奇;昙花瞬间,却能绚丽无比。