Linux VNC Server 配置心得

來源:互聯網
上載者:User
1.查詢系統是否已經安裝vnc-server執行:


rpm -qa |grep vnc
如果有類似於:
vnc-server-的值返回說明已經安裝了vnc-server2.配置vnc-server使用者

首先添加使用者:
adduser kevin
設定使用者密碼:
passwd kevin
Password:
Verify:

 

配置vnc-server的設定檔,位於:
/etc/sysconfig/vncservers
內容如下:
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# 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/vnc/sshvnc.html
                                                                                                   
# VNCSERVERS="1:myusername"
VNCSERVERS="1:tchung"----->這裡的tchung是系統裡存在的使用者VNCSERVERARGS[1]="-geometry 1024x768" ----->這裡的意思是配置使用者tchung的相關參數這裡有兩點要注意:1.VNCSERVERS=後面可以支援多使用者,以空格隔開。如:VNCSERVERS="1:myusername 15:otheruser"--->這裡的1 和15是連接埠號碼,用於串連時的連接埠2.VNCSERVERARGS後面的[]裡面的資料要與VNCSERVERS後面對應使用者的值要一致。好像不一致也沒有關係 VNCSERVERARGS基本參數有:-geometry 案頭大小,預設是1024x768
-nohttpd 不監聽HTTP連接埠
-nolisten tcp 不監聽X連接埠
-localhost 只允許從本機訪問
-AlwaysShared 預設的, 同時只能有一個vncviewer串連(跟用戶端配置也有關), 一旦第2個連上去, 第1個就被斷開了. 此參數允許同時連多個vncviewer
-SecurityTypes None登入不要求輸入密碼認證 VncAuth預設值,要密碼認證
這裡配置好了之後,我們要用vncpass來設定vnc串連時候的認證
vncpass
Password:
Verify:

注意,這裡的vncpass只能在vnc本使用者下面來運行

執行完了後,會在使用者目錄下面產生.vnc的目錄,裡面有一個檔案叫passwd然後我們啟動vncserverservice vncserver start如果沒有出錯的話,就會啟動vnc服務了。在tchung的使用者目錄下面的.vnc目錄下面會產生一些檔案,我們現在要修改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 & ---把這兩行注釋掉,加上
gnome-session &
重新啟動vncserver使用netstat -antpl查看可以發現有三個連接埠在監聽。5901 5801 6001這三個連接埠:預設的, vnc 服務監聽3個TCP連接埠
RFB(Remote FrameBuffer)協議 預設連接埠 : 5900+顯示器號
HTTP協議預設連接埠 : 5800+顯示器號
X協議 預設連接埠 : 6000+顯示器號
vncserver使用的顯示器編號預設從1開始, 依次使用, 也可以參數指定連接埠號碼我們只需要RFB協議就可以了,所以我們把5800 6000這兩種連接埠關掉。需要修改/etc/sysconfig/vncservers在參數後面加上:-nohttpd 不監聽HTTP連接埠
-nolisten tcp 不監聽X連接埠
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# 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
# For a secure way of using VNC, see
# URL:http://www.uk.research.att.com/vnc/sshvnc.html
                                                                                                    
# VNCSERVERS="1:myusername"
VNCSERVERS="1:tchung"
VNCSERVERARGS[1]="-geometry 1024x768 -nohttpd -nolisten tcp"
重啟vncserver使用vncview來串連192.168.107.109:1---->這裡的:1就是連接埠號碼 指的是5900+1 這個1是在/etc/sysconfig/vncservers裡面指定的,這個數字在100以下,不含100的時候可以直接用 192.168.107.109:1來表示,如果在vncservers裡面指定的數值大於100 包含100的時候在串連的時候就需要用到完整的連接埠數值。如:在vncservers裡面指定的是100,那麼在串連的時候就應該是這樣 的:192.168.107.109:6000vnc裡面預設是以5900這個連接埠為基礎的,這個應該是可以更改的,不過得改原始碼。
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.