日期:2014-05-16  浏览次数:20757 次

Linux 下 VncServer 配置与 Win 下 Vnc 客户端

VNC 最初由 AT&T 开发,是一个对系统进行远程管理的软件。其操作方式类似于现在 Windows 下常见的远程桌面,当然其资格比 Windows 的远程桌面更老。在 Windows 下的 VNC 软件有 RealVNC 等。
Linux 系统当然不支持 Windows 的远程桌面登录,那么我们如何用一台 Windows 的笔记本来管理一台 Linux 的服务器呢?
下载页面:
http://www.realvnc.com/products/download.html
http://www.onlinedown.net/soft/45175.htm

??????? 作者也上传了一份 Win 下 VNC Viewer 安装程序(免注册),下载地址:http://download.csdn.net/source/1080853
首先,我们当然会考虑 SSH,在 Linux 下安装 SSH 服务器,然后在 Windows 下使用 puTTY 登录进行管理(关于 puTTy 的使用与下载请进入此页:win 下 SSH 控制 Linux 工具 pietty )。
但是现在,我们不满足仅仅使用命令行方式,我们同样想使用 GUI 界面。那么:
1、在 Linux 系统下安装 VNC Server ,大多数 Linux 发行版都带了 VNC Server 的发行包。只要选择安装就可以了。
2、在 Windows 下安装 VNC 客户端 ,以 RealVNC 为例,VNC 客户端叫做 VNC Viewer。VNC 的使用相对比较简单,输入客户端的 IP,然后 VNC 会进行连接,然后弹出密码框输入密码。没有问题的话就连接上了。
3、 配置 Linux VNC Server
(1)启动 VNC 服务 ,通过 puTTY 以 SSH 方式登录服务器,假设用户名为 test。
login as: test
[test@MyServer's password:
[test@xok.la ~]$ /etc/init.d/vncserver start
Starting VNC server: no displays configured?
??????? (2)运行 vncserver 命令 ,如果第一次配置 VNC Server,会要求提供登录 VNC 使用的密码。以后也可以使用 vncpasswd 来修改密码。
[test@xok.la ~]$ vncserver
You will require a password to access your desktops.
Password:123456
Verify:123456
xauth:? creating new authority file /root/.vnc/.Xauthority
New 'xok.la.localdomain:1 (test)' desktop is xok.la.localdomain:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/xok.la.localdomain:1.log

??????? (3)此时就可以在 Windows 使用 VNC Viewer 登录了
输入服务器地址:192.168.0.64:1
然后提示输入密码,输入你刚才设定的密码就好了,如 123456
注意:IP 地址后面的 :1 的意思是 Linux 上面 VNC 设定的 Display No. 每运行一个 vncserver 就会多创建一个 Display,Display No 也就会加一。
虽然此时可以登录,但是登录后看到的界面是 X term 的界面,还不是正常的 X Window 界面,我们要修改配置,使之使用 X Window
(4)修改配置文件 /root/.vnc/xstartup ,使之与下面内容相同:
test@xok.la .vnc]$ cat 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 &

(5)保存文件,在 puTTY 终端中输入 vncserver ,让 VNC 打开一个新的 Display
test@xok.la ~]$ vncserver
New 'xok.la.localdomain:1 (test)' desktop is xok.la.localdomain:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/xok.la.localdomain:2.log

(6)使用 VNC Viewer 重新登录
Win 下 VNC Viewer 下载(包括注册码在内):http://xok.la/file/2008/11/ha_vnc-e4_2_9-x86_win32.rar 。
输入服务器地址:192.168.0.64:2。
然后提示输入密码,如 123456。
服务器地址后面的 Display No 是根据第(5)步运行的 vncserver 命令的结果来的。
New ‘xok.la.localdomain:1 (test)’ desktop is xok.la.localdomain:2。
所以 Display No 就是2,别忘记加冒号哦。
然后就看到你想要的界面了吧。
以后如果服务器重新启动后,要重新输入 vncserver 后登录。如果服务器一直开机,就不用了。
如果要杀掉 vncserver 进程,可执行 vncserver :1 kill ,1表示 display 的 ID 号。
原文链接:http://xok.la/2008/11/linux_vncserver_win_client.html