天天看點

VNC資料整理

檢視是否安裝過VNC

rpm -qa | grep tigervnc

VNC server安裝

#yum install tigervnc tigervnc-server –y

設定密碼

#vncserver

設定使用者資訊和分辨率

vim /etc/sysconfig/vncservers

關閉防火牆

#service iptables stop

檢視防火牆狀态

#service iptables status

VNCSERVER密碼忘了

1.  cd /root/.vnc/  

2.    

3.  rm -rf passwd  

4.  vncserver

5.  重新設定密碼

4、打開對應的端口打開5901至5902 端口用于vnc //如果需要配置更多的桌面,增加端口即可

iptables-I INPUT -p tcp --dport 5901:5902 -j ACCEPT

iptables-A INPUT -p tcp --dport 5901:5902 -j ACCEPT

永久儲存

serviceiptables save

停止vncserver

設定使用者資訊及分辨率。

[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

# <<A href="http://www.uk.research.att.com/archive/vnc/sshvnc.html">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伺服器端就配置完成了。

編輯vnc配置檔案

vi /etc/sysconfig/vncservers

在最後加上:

VNCSERVERS="1:user1 2:user2"

VNCSERVERSVNCSERVERARGS[1]="-geometry 1024x768 -alwaysshared" 

VNCSERVERSVNCSERVERARGS[2]="-geometry 1024x768 -alwaysshared"

注意:-geometry 1024x768表示分辨率;-alwaysshared 表示允許多終端同時登陸

4、打開對應的端口打開5901至5902 端口用于vnc  //如果需要配置更多的桌面,增加端口即可

iptables -I INPUT -p tcp --dport 5901:5902 -j ACCEPT

iptables -A INPUT -p tcp --dport 5901:5902 -j ACCEPT

service iptables save

4.啟動vncserver服務

1)啟動全部桌面

  service vncserver start

2)啟動某一桌面

  vncserver :1  //這裡1表示第一個桌面

5、停止vncserver服務1)停止全部桌面

  service vncserver stop

2) 停止某一桌面

    vncserver -kill :1  //停止第1個界面,要用kill指令來殺掉界面1的程序

6、檢視目前有幾個桌面在運作    service vncserver status

7、讓vncserver服務随機啟動預設狀态下,vncserver服務不是開機自動啟動,需要手工啟動。

chkconfig --list vncserver

chkconfig vncserver on

儲存後,重新開機測試。

8.用戶端登入vncserver服務(1)先安裝vncviewer來遠端登入,

(2)然後在位址欄輸入“主機位址:1”(即主機IP加界面号的方式)

9、開機自動啟動vncserver

# chkconfig vncserver on

VNC資料整理

 檢視是否設定成功

VNC資料整理

10、關閉自動啟動

# chkconfig vncserver off

檢視是否關閉自動啟動

VNC資料整理

本文轉自 是阿傑啊 51CTO部落格,原文連結:http://blog.51cto.com/jschinamobile/1983529