linux vnc配置指南
原文:http://blog.chinaunix.net/u/1281/showart_1982905.html
【實驗】【VNC】Linux環境VNC服務安裝、配置與使用
1.確認VNC是否安裝
預設情況下,Red Hat Enterprise Linux安裝程式會將VNC服務安裝在系統上。
確認是否已經安裝VNC服務及檢視安裝的VNC版本
[root@testdb ~]# rpm -q vnc-server
vnc-server-4.1.2-9.el5
[root@testdb ~]#
若系統沒有安裝,可以到作業系統安裝盤的Server目錄下找到VNC服務的RPM安裝包vnc-server-4.1.2-9.el5.x86_64.rpm,安裝命令如下
rpm -ivh /mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm
2.啟動VNC服務
使用vncserver命令啟動VNC服務,命令格式為“vncserver :桌面號”,其中“桌面號”用“數字”的方式表示,每個使用者連個需要佔用1個桌面
啟動編號為1的桌面示例如下
[root@testdb ~]# vncserver :1
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /root/.Xauthority
New 'testdb:1 (root)' desktop is testdb:1
Creating default startup script. /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log
以上命令執行的過程中,因為是第一次執行,需要輸入密碼,這個密碼被加密儲存在使用者主目錄下的.vnc子目錄(/root/.vnc/passwd)中;同時在使用者主目錄下的.vnc子目錄中為使用者自動建立xstartup配置檔案(/root/.vnc/xstartup),在每次啟動VND服務時,都會讀取該檔案中的配置資訊。
BTW:/root/.vnc/目錄下還有一個“testdb:1.pid”檔案,這個檔案記錄著啟動VNC後對應後天作業系統的程式號,用於停止VNC服務時準確定位程式號。
3.VNC服務使用的埠號與桌面號的關係
VNC服務使用的埠號與桌面號相關,VNC使用TCP埠從5900開始,對應關係如下
桌面號為“1” ---- 埠號為5901
桌面號為“2” ---- 埠號為5902
桌面號為“3” ---- 埠號為5903
……
基於Java的VNC客戶程式Web服務TCP埠從5800開始,也是與桌面號相關,對應關係如下
桌面號為“1” ---- 埠號為5801
桌面號為“2” ---- 埠號為5802
桌面號為“3” ---- 埠號為5803
……
基於上面的介紹,如果Linux開啟了防火牆功能,就需要手工開啟相應的埠,以開啟桌面號為“1”相應的埠為例,命令如下
[root@testdb ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
[root@testdb ~]# iptables -I INPUT -p tcp --dport 5801 -j ACCEPT
4.測試VNC服務
第一種方法是使用VNC Viewer軟體登陸測試,操作流程如下
啟動VNC Viewer軟體 --> Server輸入“144.194.192.183:1” --> 點選“OK” --> Password輸入登陸密碼 --> 點選“OK”登陸到X-Window圖形桌面環境 --> 測試成功
第二種方法是使用Web瀏覽器(如Firefox,IE,Safari)登陸測試,操作流程如下
位址列輸入 --> 出現VNC viewer for Java(此工具是使用Java編寫的VNC客戶端程式)介面,同時跳出VNC viewer對話方塊,在Server處輸入“144.194.192.183:1”點選“OK” --> Password輸入登陸密碼 --> 點選“OK”登陸到X-Window圖形桌面環境 --> 測試成功
(注:VNC viewer for Java需要JRE支援,如果頁面無法顯示,表示沒有安裝JRE,可以到這裡下載最新的JRE進行安裝)
5.配置VNC圖形桌面環境為KDE或GNOME桌面環境
如果您是按照我的上面方法進行的配置的,登陸到桌面後效果是非常簡單的,只有一個Shell可供使用,這是為什麼呢?怎麼才能看到可愛並且美麗的KDE或GNOME桌面環境呢?回答如下
之所以那麼的難看,是因為VNC服務預設使用的是twm圖形桌面環境的,可以在VNC的配置檔案xstartup中對其進行修改,先看一下這個配置檔案
[root@testdb ~]# cat /root/.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 &
將這個xstartup檔案的最後一行修改為“startkde &”,再重新啟動vncserver服務後就可以登陸到KDE桌面環境
將這個xstartup檔案的最後一行修改為“gnome-session &”,再重新啟動vncserver服務後就可以登陸到GNOME桌面環境
重新啟動vncserver服務的方法:
[root@testdb ~]# vncserver -kill :1
[root@testdb ~]# vncserver :1
6.配置多個桌面
可以使用如下的方法啟動多個桌面的VNC
vncserver :1
vncserver :2
vncserver :3
……
但是這種手工啟動的方法在伺服器重新啟動之後將失效,因此,下面介紹如何讓系統自動管理多個桌面的VNC,方法是將需要自動管理的資訊新增到/etc/sysconfig/vncservers配置檔案中,先以桌面1為root使用者桌面2為oracle使用者為例進行配置如下:
格式為:VNCSERVERS="桌面號:使用的使用者名稱桌面號:使用的使用者名稱"
[root@testdb ~]# vi /etc/sysconfig/vncservers
VNCSERVERS="1:root 2:oracle"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"
7.修改VNC訪問的密碼
使用命令vncpasswd對不同使用者的VNC的密碼進行修改,一定要注意,如果配置了不同使用者的VNC需要分別到各自使用者中進行修改,例如在我的這個實驗中,root使用者和oracle使用者需要分別修改,修改過程如下:
[root@testdb ~]# vncpasswd
Password:
Verify:
[root@testdb ~]#
8.啟動和停止VNC服務
1)啟動VNC服務命令
[root@testdb ~]# /etc/init.d/vncserver start
Starting VNC server: 1:root
New 'testdb:1 (root)' desktop is testdb:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log
2:oracle
New 'testdb:2 (oracle)' desktop is testdb:2
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log
[ OK ]
2)停止VNC服務命令
[root@testdb ~]# /etc/init.d/vncserver stop
Shutting down VNC server: 1:root 2:oracle [ OK ]
3)重新啟動VNC服務命令
[root@testdb ~]# /etc/init.d/vncserver restart
Shutting down VNC server: 1:root 2:oracle [ OK ]
Starting VNC server: 1:root
New 'testdb:1 (root)' desktop is testdb:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log
2:oracle
New 'testdb:2 (oracle)' desktop is testdb:2
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log
[ OK ]
4)設定VNC服務隨系統啟動自動載入
第一種方法:使用“ntsysv”命令啟動圖形化服務配置程式,在vncserver服務前加上星號,點選確定,配置完成。
第二種方法:使用“chkconfig”在命令列模式下進行操作,命令使用如下(預知chkconfig詳細使用方法請自助式man一下)
[root@testdb ~]# chkconfig vncserver on
[root@testdb ~]# chkconfig --list vncserver
vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off
【實驗】【VNC】Linux環境VNC服務安裝、配置與使用
1.確認VNC是否安裝
預設情況下,Red Hat Enterprise Linux安裝程式會將VNC服務安裝在系統上。
確認是否已經安裝VNC服務及檢視安裝的VNC版本
[root@testdb ~]# rpm -q vnc-server
vnc-server-4.1.2-9.el5
[root@testdb ~]#
若系統沒有安裝,可以到作業系統安裝盤的Server目錄下找到VNC服務的RPM安裝包vnc-server-4.1.2-9.el5.x86_64.rpm,安裝命令如下
rpm -ivh /mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm
2.啟動VNC服務
使用vncserver命令啟動VNC服務,命令格式為“vncserver :桌面號”,其中“桌面號”用“數字”的方式表示,每個使用者連個需要佔用1個桌面
啟動編號為1的桌面示例如下
[root@testdb ~]# vncserver :1
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /root/.Xauthority
New 'testdb:1 (root)' desktop is testdb:1
Creating default startup script. /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log
以上命令執行的過程中,因為是第一次執行,需要輸入密碼,這個密碼被加密儲存在使用者主目錄下的.vnc子目錄(/root/.vnc/passwd)中;同時在使用者主目錄下的.vnc子目錄中為使用者自動建立xstartup配置檔案(/root/.vnc/xstartup),在每次啟動VND服務時,都會讀取該檔案中的配置資訊。
BTW:/root/.vnc/目錄下還有一個“testdb:1.pid”檔案,這個檔案記錄著啟動VNC後對應後天作業系統的程式號,用於停止VNC服務時準確定位程式號。
3.VNC服務使用的埠號與桌面號的關係
VNC服務使用的埠號與桌面號相關,VNC使用TCP埠從5900開始,對應關係如下
桌面號為“1” ---- 埠號為5901
桌面號為“2” ---- 埠號為5902
桌面號為“3” ---- 埠號為5903
……
基於Java的VNC客戶程式Web服務TCP埠從5800開始,也是與桌面號相關,對應關係如下
桌面號為“1” ---- 埠號為5801
桌面號為“2” ---- 埠號為5802
桌面號為“3” ---- 埠號為5803
……
基於上面的介紹,如果Linux開啟了防火牆功能,就需要手工開啟相應的埠,以開啟桌面號為“1”相應的埠為例,命令如下
[root@testdb ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
[root@testdb ~]# iptables -I INPUT -p tcp --dport 5801 -j ACCEPT
4.測試VNC服務
第一種方法是使用VNC Viewer軟體登陸測試,操作流程如下
啟動VNC Viewer軟體 --> Server輸入“144.194.192.183:1” --> 點選“OK” --> Password輸入登陸密碼 --> 點選“OK”登陸到X-Window圖形桌面環境 --> 測試成功
第二種方法是使用Web瀏覽器(如Firefox,IE,Safari)登陸測試,操作流程如下
位址列輸入 --> 出現VNC viewer for Java(此工具是使用Java編寫的VNC客戶端程式)介面,同時跳出VNC viewer對話方塊,在Server處輸入“144.194.192.183:1”點選“OK” --> Password輸入登陸密碼 --> 點選“OK”登陸到X-Window圖形桌面環境 --> 測試成功
(注:VNC viewer for Java需要JRE支援,如果頁面無法顯示,表示沒有安裝JRE,可以到這裡下載最新的JRE進行安裝)
5.配置VNC圖形桌面環境為KDE或GNOME桌面環境
如果您是按照我的上面方法進行的配置的,登陸到桌面後效果是非常簡單的,只有一個Shell可供使用,這是為什麼呢?怎麼才能看到可愛並且美麗的KDE或GNOME桌面環境呢?回答如下
之所以那麼的難看,是因為VNC服務預設使用的是twm圖形桌面環境的,可以在VNC的配置檔案xstartup中對其進行修改,先看一下這個配置檔案
[root@testdb ~]# cat /root/.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 &
將這個xstartup檔案的最後一行修改為“startkde &”,再重新啟動vncserver服務後就可以登陸到KDE桌面環境
將這個xstartup檔案的最後一行修改為“gnome-session &”,再重新啟動vncserver服務後就可以登陸到GNOME桌面環境
重新啟動vncserver服務的方法:
[root@testdb ~]# vncserver -kill :1
[root@testdb ~]# vncserver :1
6.配置多個桌面
可以使用如下的方法啟動多個桌面的VNC
vncserver :1
vncserver :2
vncserver :3
……
但是這種手工啟動的方法在伺服器重新啟動之後將失效,因此,下面介紹如何讓系統自動管理多個桌面的VNC,方法是將需要自動管理的資訊新增到/etc/sysconfig/vncservers配置檔案中,先以桌面1為root使用者桌面2為oracle使用者為例進行配置如下:
格式為:VNCSERVERS="桌面號:使用的使用者名稱桌面號:使用的使用者名稱"
[root@testdb ~]# vi /etc/sysconfig/vncservers
VNCSERVERS="1:root 2:oracle"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"
7.修改VNC訪問的密碼
使用命令vncpasswd對不同使用者的VNC的密碼進行修改,一定要注意,如果配置了不同使用者的VNC需要分別到各自使用者中進行修改,例如在我的這個實驗中,root使用者和oracle使用者需要分別修改,修改過程如下:
[root@testdb ~]# vncpasswd
Password:
Verify:
[root@testdb ~]#
8.啟動和停止VNC服務
1)啟動VNC服務命令
[root@testdb ~]# /etc/init.d/vncserver start
Starting VNC server: 1:root
New 'testdb:1 (root)' desktop is testdb:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log
2:oracle
New 'testdb:2 (oracle)' desktop is testdb:2
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log
[ OK ]
2)停止VNC服務命令
[root@testdb ~]# /etc/init.d/vncserver stop
Shutting down VNC server: 1:root 2:oracle [ OK ]
3)重新啟動VNC服務命令
[root@testdb ~]# /etc/init.d/vncserver restart
Shutting down VNC server: 1:root 2:oracle [ OK ]
Starting VNC server: 1:root
New 'testdb:1 (root)' desktop is testdb:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log
2:oracle
New 'testdb:2 (oracle)' desktop is testdb:2
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log
[ OK ]
4)設定VNC服務隨系統啟動自動載入
第一種方法:使用“ntsysv”命令啟動圖形化服務配置程式,在vncserver服務前加上星號,點選確定,配置完成。
第二種方法:使用“chkconfig”在命令列模式下進行操作,命令使用如下(預知chkconfig詳細使用方法請自助式man一下)
[root@testdb ~]# chkconfig vncserver on
[root@testdb ~]# chkconfig --list vncserver
vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-669465/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- centOS5.5配置vnc,開啟linux遠端桌面CentOSVNCLinux
- openEuler 配置VNC ServerVNCServer
- VNC安裝配置VNC
- linux遠端工具vnc啟用,linux遠端工具vnc如何啟用,Linux安裝vnc教程。LinuxVNC
- VNC,Linux遠端VNC連線伺服器!VNCLinux伺服器
- vnc遠端連線linux,vnc遠端連線linux的具體操作VNCLinux
- vnc遠端連線linux,vnc遠端連線linux的具體方法。VNCLinux
- VNC,Linux系統下如何安裝和連線VNC!VNCLinux
- Linux系統安裝VNCLinuxVNC
- vnc批次登入,2種VNC批次登入Linux的方法VNCLinux
- vnc使用教程,10個步驟教你在Linux中使用VNCVNCLinux
- vnc批次登入,vnc批次登入Linux的方法介紹VNCLinux
- vnc管理工具,vnc管理工具安裝使用教程,linux如何安裝vnc server?VNCLinuxServer
- vnc安裝步驟,4個vnc安裝步驟實現vnc與Linux的連線VNCLinux
- VNC安裝配置詳細說明VNC
- CentOS 8.2下VNC安裝與配置CentOSVNC
- CentOS使用配置VNC遠端連線CentOSVNC
- vnc遠端安裝,在Linux中vnc遠端安裝的教程VNCLinux
- vnc安裝步驟,如何在Linux(CentOS 7)下vnc安裝步驟VNCLinuxCentOS
- CentOS 7 配置 VNC 遠端桌面連線CentOSVNC
- AIX6.1下安裝及配置VNCAIVNC
- VNC,什麼是VNC,如何使用VNC?VNC
- linux定時任務的設定 crontab 配置指南Linux
- vnc遠端連線黑屏,vnc連線Linux後黑屏的處理辦法VNCLinux
- vnc安裝步驟,4個在Linux下vnc的個安裝步驟VNCLinux
- vnc viewer中文版,8步驟在Linux中安裝vnc viewer中文版VNCViewLinux
- VNC,VNC連線操作!VNC
- VNC,VNC軟體下載!VNC
- VNC, VNC viewer使用方法!VNCView
- vnc遠端安裝,10個步驟在Linux中遠端安裝VNC並連線VNCLinux
- VNC連線,VNC如何連線WindowsVNCWindows
- VNC遠端控制軟體:VNC Server for MacVNCServerMac
- VNC,VNC遠端不了如何解決?VNC
- VNC Server for Mac(VNC遠端控制軟體)VNCServerMac
- linux操作指南-01Linux
- header的安全配置指南Header
- RedHat Linux 6企業版開啟VNC Server遠端桌面RedhatLinuxVNCServer
- vnc viewer西西軟體,vnc viewer西西軟體推薦,vnc客戶端使用教程VNCView客戶端
- 安裝vncVNC