RedHat Linux 5企業版開啟VNCSERVER遠端桌面功能

來源:互聯網
上載者:User
RedHat Linux 5企業版開啟VNCSERVER遠端桌面功能

環境:RedHat Linux 5企業版。
Xwindows:gnome (紅帽預設安裝的圖形介面)

儘管我們可以使用SSH串連遠程通過字元介面來操作Linux,但是對於更多熟悉圖形人來說是很不方便的,因此開啟Linux的遠端桌面還是很有必要的。目前有兩種比較流行的方式:XDM(X display manager)方案和VNC方案,而我個人比較傾向於VNC方案,一是因為VNC方案配置起來相對比較容易,二是VNC方案支援多種串連方式,比如通過瀏覽器訪問Linux案頭,免去需要安裝用戶端的麻煩。

接下來進入具體配置說明:

一, 確認及安裝VNCSERVER。

1,首先確認你伺服器是否配置了VNCSERVER,可以在命令列下敲入以下命令查看:

[root@localhost: ~]#rpm -qa |grep vnc

vnc-server-4.1.2-14.el5 #返回VNCSEVER伺服器端版本說明你已經安裝了VNCSERVER。

2,如果沒有安裝VNCSEVER,那麼從光碟片找到安裝包進行安裝。

首先將光碟片掛載(也叫解壓)到某個目錄這裡是在/var/ftp/pub/下面建立了rhel5-64目錄

mount -o loop rhel-server-5.3-x86_64-dvd.iso /var/ftp/pub/rhel5-64/

然後在/var/ftp/pub/rhel5-64/Server目錄下找到 vnc-server-4.1.2-14.el5.x86_64.rpm安裝包,使用RPM命令直接安裝;

rpm -ivh vnc-server-4.1.2-14.el5.x86_64.rpm


二,開始配置VNCSERVER

1,啟動VNCSERVER,第一次啟動VNCSERVER會提示輸入密碼,這裡分為管理員賬戶及普通賬戶,啟動方式略有所不同。

管理員:

[root@localhost /]# vncserver

You will require a password to access your desktops.

Password: 123456 #輸入vnc 串連密碼

Verify: 123456 #確認vnc密碼

xauth: creating new authority file /root/.Xauthority

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

普通使用者:

[root@localhost /]#su ceboy #ceboy 是使用者名稱
[ceboy@localhost /]$ vncserver

You will require a password to access your desktops.

Password: 123456 #輸入vnc 串連密碼

Verify: 123456 #確認vnc密碼

xauth: creating new authority file /home/ceboy/.Xauthority

New ‘localhost.localdomain:2 (ceboy)’ desktop is localhost.localdomain:2

Creating default startup script /home/ceboy/.vnc/xstartup
Starting applications specified in /home/ceboy/.vnc/xstartup
Log file is /home/ceboy/.vnc/localhost.localdomain:2.log

#這裡要注意:每個使用者都可以啟動自己的VNCSERVER遠端桌面,同時每個使用者可以啟動多個VNCSERVER遠端桌面,它們用ip加連接埠號碼:ip:1、ip:2、ip:3 來標識、區分,使用同一連接埠會使另外登入的使用者自動結束。另,VNCSERVER的大部分設定檔及記錄檔都在使用者home目錄下.vnc目錄下。

使用者可以自訂啟動號碼如:

[ceboy@localhost /]$ vncserver :2 #注意:2前面一定要有空格。
A VNC server is already running as :2

三,相關案頭配置,RedHat Linux支援兩種圖形模式:KDE模式和gnome模式。

1,你的RH使用的什麼圖形模式這個一般只有登入到圖形介面查看一下才能知道,或者通過ps -A命令列出所有當前啟動並執行程式,看看有沒有KDE或者gnome字樣來判斷一下。

如果你是gnome案頭,那麼你需要修改/root/.vnc/xstartup的設定檔。

[root@localhost .vnc]# vi 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 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &

gnome-session gnome #添加這一句是串連時使用gnome 案頭環境

twm &

設定修改完畢最好是重啟一次系統,否則設定不會生效。我採用的方法是殺死VNCSERVER進程再重運行VNCSERVER。

[root@localhost .vnc]#vncserver -kill :1 #這裡你啟動vncserver時是什麼連接埠號碼要對應上。
[root@localhost .vnc]#vncserver :1 #重啟VNCSERVER,注意:1前面一定要有空格。

2,設定使用者資訊及解析度。

[root@localhost: ~]#vi /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=”1:root 2:ceboy” #此處添加使用者,一般只添加一個1:root也就行了。

VNCSERVERARGS[1]=”-geometry 800×600 -nolisten tcp -nohttpd -localhost”
VNCSERVERARGS[2]=”-geometry 1024×768 -nolisten tcp -nohttpd -localhost”

#注意:上面是分別設定的root和ceboy兩個使用者的解析度,注意是用連接埠號碼區分的。

另外也可以通過命令列臨時修改解析度及色深,這種方式重啟後就會丟失,這裡暫時用不到,命令如下:

[root@localhost: ~]#vncserver -geometry 800×600 #設定vncserver的解析度

[root@localhost: ~]#vncserver -depth 16 #設定vncserver的色深

到這裡VNCSERVER伺服器端就配置完成了。

四,用戶端串連及使用。

1,訪問方式
a、在linux下,運行vncviewer命令即可,伺服器位址的寫法形如192.168.1.11:1
b、在windows下,運行windows版本的vncviewer即可,用法與linux下相近。
c、用瀏覽器(平台無關),作為java applet來實現,以形如http://192.168.1.11:5801 的方式來啟動 (vnc 連接埠從5800 開始依次類推,一般會是5800,5900)

以下為一些常識:

2,修改密碼

運行vncpasswd即可

3,停止vncserver

#vncserver -kill :1
#vncserver -kill :2

注意到vncserver只能由啟動它的使用者來關閉,即時是root也不能關閉其它使用者開啟的vncserver,只能用kill命令暴力殺死進程。

4,穩定性設定

vncserver預設在多個客戶機串連同一個vncserver的顯示連接埠時,vncserver連接埠舊串連,而為新串連服務,可通過-dontdisconnect拒絕新串連請求而保持舊的串連。

5,同一個顯示器可以串連多個客戶機

#vncserver -alwaysshared

6,重啟服務

service vncserver restart

7,讓系統啟動時自動啟動VNCSERVER。

使用VNC串連登入到RedHat Linux圖形介面,點擊“系統”——“管理”——“伺服器設定”——“服務”,在“後台服務”中找到VNCSERVER後勾選它,點擊儲存即可。

 

PS:百度文庫上有一篇不錯的文檔:

http://wenku.baidu.com/view/ea6a46641ed9ad51f01df25a.html

來源:http://www.cnblogs.com/mac_arthur/archive/2011/11/8.html

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.