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
首先,我們當然會考慮SSH,在linux下安裝SSH伺服器,然後在windows下使用puTTY登入進行管理.
但是現在,我們不滿足僅僅使用命令列方式,我們同樣想使用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 [ OK ]
(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號