VNC概述
梁溪ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!
VNC (Virtual Network Computing)是虛擬網(wǎng)絡(luò)計算機的縮寫。VNC是一款優(yōu)秀的遠(yuǎn)程控制工具軟件,由著名的AT&T的歐洲研究實驗室開發(fā)的。VNC是在基于UNIX和Linux操作系統(tǒng)的免費的開源軟件,遠(yuǎn)程控制能力強大,高效實用,其性能可以和Windows或MAC中的任何遠(yuǎn)程控制軟件媲美。在 Linux中,VNC包括以下四個命令:vncserver,vncviewer,vncpasswd,和 vncconnect。大多數(shù)情況下只需要其中的兩個命令:vncserver和 vncviewer。目前,原來的AT&T版本已經(jīng)不再使用,因為更多有重大改善的分支版本已經(jīng)出現(xiàn), 像是RealVNC, VNC tight和UltraVNC。 Real VNC是當(dāng)前最活躍和強大的主流應(yīng)用。
RealVNC官方網(wǎng)址 : http://www.realvnc.com/
Tight VNC官方網(wǎng)址: http://www.tightvnc.com/
UltraVNC官方網(wǎng)址 :http://www.uvnc.com/
VNC原理
VNC系統(tǒng)由客戶端,服務(wù)端和一個協(xié)議組成。VNC的服務(wù)端目的是分享其所運行機器的屏幕, 服務(wù)端被動的允許客戶端控制它。 VNC客戶端(或Viewer) 觀察控制服務(wù)端,與服務(wù)端交互。 VNC協(xié)議 Protocol (RFB)是一個簡單的協(xié)議,傳送服務(wù)端的原始圖像到客戶端(一個X,Y位置上的正方形的點陣數(shù)據(jù)), 客戶端傳送事件消息到服務(wù)端。
服務(wù)器發(fā)送小方塊的幀緩存給客戶端,在最簡單的情況,VNC協(xié)議使用大量的帶寬,因此各種各樣的方法被發(fā)明出來減少通訊的開支,舉例來說,有各種各樣的編碼方法來決定最有效率的方法來傳送這些點陣方塊)
協(xié)議允許客戶端和服務(wù)端去協(xié)議哪種編碼會被使用,最簡單的編碼,被大多數(shù)客戶端和服務(wù)端所支持的是, 從左到右的像素掃描數(shù)據(jù)的原始編碼, 當(dāng)原始的滿屏被發(fā)送后,只發(fā)送變化的方塊區(qū)域。這種編碼在幁間只有小部分屏幕變化的情況下工作的非常好(像是鼠標(biāo)鍵在桌面移動的情況,或在光標(biāo)處敲擊文字),不過如果大量的像素同時變化帶寬將會增加的非常高,像是拖動一個窗口或觀看全屏錄像。
VNC默認(rèn)使用TCP端口5900至5906,而JAVA的VNC客戶端使用5800至5806。一個服務(wù)端可以在5500口用“監(jiān)聽模式”連接一個客戶端,使用監(jiān)聽模式的一個好處是服務(wù)端不需要設(shè)置防火墻。
UNIX上的VNC稱為xvnc,同時扮演兩種角色,對X窗口系統(tǒng)的應(yīng)用程序來說它是X server,對于VNC客戶端來說它是VNC服務(wù)器程序。
實驗環(huán)境
VNC服務(wù)端:
操作系統(tǒng):Red Hat Enterprise Linux Server release 5.7 (Tikanga)
VNC客戶端:
操作系統(tǒng):Windows 7專業(yè)版 64位操作系統(tǒng)
VNC安裝配置
1、安裝VNC包
[root@localhost /]# cd /depot/os/mnt/cdrom/Server
[root@localhost /]# rpm -ivh vnc-server-4.1.2-14.el5_6.6.x86_64.rpm
[root@localhost /]# rpm -ivh vnc-4.1.2-14.el5_6.6.x86_64.rpm
驗證vnc-server包是否安裝成功:
[root@localhost /]# rpm -qa vnc-server
vnc-server-4.1.2-14.el5_6.6
2、配置vncservers文件
修改/etc/sysconfig/vncservers文件,未經(jīng)修改的vncservers文件如下所示:
[root@localhost ~]# more /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
# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-nohttpd" to prevent web-based VNC clients connecting.
# 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 800x600 -nolisten tcp -nohttpd -localhost"
將最后兩行配置信息取消注釋,添加系統(tǒng)賬號
VNCSERVERS="1:root 2:etl"
VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd "
VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -nohttpd "
VNCSERVERS是用來設(shè)定可以使用VNC的服務(wù)器賬號,可以設(shè)定多個,例如上面root、etl,但是中間要用空格隔開。使用VNCVIEWER登錄時,192.168.48.128:1表示是以root賬號登錄,以此類推。
關(guān)于參數(shù)配置說明:
1:-geometry表示桌面分辨率,默認(rèn)為1024x768,所以上面的1024x768也可以不寫。
2:-nohttpd 表示不監(jiān)聽HTTP端口(58xx)。
3:-nolisten tcp表示不監(jiān)聽TCP端口(60xx)
4:-localhost只運行從本機訪問。
5:AlwaysShared默認(rèn)只允許一個VNCVIEWER連接,此參數(shù)表示同一個顯示端口允許多用戶同時登錄.
6:-depth 表示色深,參數(shù)有8,16,24,32.
7: SecurityTypes None登錄不需要密碼認(rèn)證VncAuth默認(rèn)值,要密碼認(rèn)證。
3、設(shè)置VNC用戶密碼
如果此時不設(shè)置VNC用戶密碼,啟動vncserver服務(wù),則會報如下錯誤:
[root@localhost ~]# service vncserver start
Starting VNC server: 1:root [FAILED]
[root@localhost /]# vncpasswd
Password:
Verify:
[root@localhost /]# su - etl
[etl@localhost ~]$ vncpasswd
Password:
Verify:
[etl@localhost ~]$
4、啟動vncserver服務(wù)
[root@localhost ~]# service vncserver start
Starting VNC server: 1:root
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
2:etl
New 'localhost.localdomain:2 (etl)' desktop is localhost.localdomain:2
Creating default startup script /home/etl/.vnc/xstartup
Starting applications specified in /home/etl/.vnc/xstartup
Log file is /home/etl/.vnc/localhost.localdomain:2.log
[ OK ]
VNC會在用戶根目錄($HOME)下的".vnc"文件夾下生成一系列文件。其中passwd為vnc用戶密碼文件,由vncpasswd生成。其他的都由vnc初次啟動時生成,xstartup為VNC客戶端連接時啟動的腳本
5、配置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 &
切換到etl賬號,依法炮制
[root@localhost ~]# su - etl
[etl@localhost ~]$ vi /home/etl/.vnc/xstartup
[root@localhost ~]# service vncserver restart
Shutting down VNC server: 1:root 2:etl [ OK ]
Starting VNC server: 1:root
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
2:etl
New 'localhost.localdomain:2 (etl)' desktop is localhost.localdomain:2
Starting applications specified in /home/etl/.vnc/xstartup
Log file is /home/etl/.vnc/localhost.localdomain:2.log
[ OK ]
6、配置防火墻
如果你不配置防火墻,此時用VNC Viewer連接的話,一般會報:"connect:Connection timed out(10060)"錯誤,如下所示:
一般這種情況要么關(guān)閉防火墻,要么需要配置防火墻。
[root@localhost ~]# service iptables stop
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
關(guān)閉防火墻后,用VNCView連接服務(wù)器沒有問題,但是一般不建議關(guān)閉防火墻,
[root@localhost ~]# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_ns [ OK ]
[root@localhost ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
[root@localhost ~]# iptables -I INPUT -p tcp --dport 5902 -j ACCEPT
OK,可以通過VNC連接到服務(wù)器了
關(guān)于VNC服務(wù)使用的端口號與桌面號相關(guān),VNC使用TCP端口從5900開始,對應(yīng)關(guān)系如下
桌面號為“1” ----端口號為5901
桌面號為“2” ----端口號為5902
桌面號為“3” ----端口號為5903
……
基于Java的VNC客戶程序Web服務(wù)TCP端口從5800開始,也是與桌面號相關(guān),對應(yīng)關(guān)系如下
桌面號為“1” ----端口號為5801
桌面號為“2” ----端口號為5802
桌面號為“3” ----端口號為5803
基于上面的介紹,如果Linux開啟了防火墻功能,就需要手工開啟相應(yīng)的端口,以開啟桌面號為“1”相應(yīng)的端口為例,命令如下
開機自啟動vncserver服務(wù)
# chkconfig vncserver on
網(wǎng)站名稱:VNC安裝配置詳細(xì)說明
文章位置:http://jinyejixie.com/article36/ipggpg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、網(wǎng)站營銷、網(wǎng)站建設(shè)、營銷型網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)