上一篇文章我們成功配置遠端登入的相關檔案,那麼這一篇文章我們再一次把眼光聚焦到vnc的配置檔案vncservers身上。
我們再次檢視vncservers的内容,其内容如下:
[root@localhost ~]# cat /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 800×600 -nolisten tcp -nohttpd -localhost"
在上一篇文章我說過對于我們來說,最主要的是被标注出來的這兩行代碼。下面我們對這兩行一一作注解。
此行是用來設定遠端登入的使用者及桌面号的
此行是用來設定相應使用者的登陸桌面的,在此我要說的是相應使用者,而不是所有使用者是有原因的。
其中:
-geometry代表使用kde桌面
800×600表示使用登陸後桌面的分辨率
-localhost代表不允許當地使用者登入
-alwaysshared 代表允許多使用者同時登入 (此行配置沒有出現)
-depth 代為色深,參數有 8,16,24,32
-nolisten和-nohttpd我們很少使用到在此就不做更多的解釋了
請大家注意“vncserverargs[2]”中的數字“2”,這個2是和vncservers="2: myusername"中的2是對應的。也就是說vncservers="2: myusername"中對應的使用者所使用的桌面設定是和vncserverargs[*]中相對應的。
為了能更好的說明問題,我現在進行實際的操作進行說明問題。
現在的配置檔案我修改如下:
vncservers="1:root 2:lanni 3:jinyang"
vncserverargs[1]="-geometry 800×600 -alwaysshared -nolisten tcp –nohttpd -localhost "
整段配置的意義是使用者root、lanni、jinyang三個使用者共同使用使用者root的桌面配置。
請注意此配置有兩點需要注意:
第一:-alwaysshared 這個是使用者root把自己的桌面共享出來
第二:-localhost這個我在上面介紹過了,它是拒絕本地使用者遠端的,也即是說,使用者lanni和jinyang這兩個使用者是可以登入的,而root無法遠端登入的。
那麼是不是這種效果呢?我們配置好,重新開機伺服器即可。

重新開機後我們先使用root的桌面号進行登入:
我們可以很明顯的看到root是不能登入的,那麼其他使用者呢?
我們現在可以很明顯的看到使用者lanni桌面号為2,使用者jinyang桌面号為3,現在是可以正常的登陸的。
這也就是說明了,字段“-localhost”确實起到阻止使用者root登入的目的。那麼如果我們現在去掉該字段“-localhost”,root使用者是不是可以正常登陸呢?
重新開機後,登陸結果如下:
可以看到使用者root、lanni、jiyang都可以登入了。
這也給了我們一個啟發,盡管我們已經允許root使用者登入,但是我們可以通過這種方式阻止root的登陸,同理我們也可以阻止其他使用者的登陸。
我現在把這個配置使用者的其他形式,也寫出來如下: