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 的 識別碼。
原文連結:http://xok.la/2008/11/linux_vncserver_win_client.html