vncserverの設定例 - CentOS/RHEL

vncserverの設定方法を示す。

概要
rootユーザーとownerユーザーを設定する例を記載。
内容
/etc/sysconfig/vncserversの編集
(変更後)
VNCSERVERS="1:root 2:owner"
VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -nohttpd"

(変更前)
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
vncパスワードの設定
# su - owner
$ vncpasswd
Password:
Verify:
$ exit
# vncpasswd
Password:
Verify:
vncserverサービスの有効化
# chkconfig --list | grep vncserver
vncserver       0:off   1:off   2:off   3:off   4:off   5:off   6:off
# chkconfig vncserver on
# chkconfig --list | grep vncserver
vncserver       0:off   1:off   2:on    3:on    4:on    5:on    6:off
#
vncserverサービスの起動
# service vncserver start
VNC サーバー を起動中: 1:root 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

2:owner xauth:  creating new authority file /home/owner/.Xauthority
New 'localhost.localdomain:2 (owner)' desktop is localhost.localdomain:2

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

                                                           [  OK  ]
#
~/.vnc/xstartupの編集
以下のコマンドラインからxstartupを編集
(rootユーザの場合)
# vi ~/.vnc/xstartup
(ownerユーザの場合)
# su - owner
$ vi ~/.vnc/xstartup
$ exit
(編集前)
#!/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 &

(編集後)
#!/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 &
vncserverの再起動
# service vncserver stop
VNC サーバー を停止中: 1:root 2:owner                      [  OK  ]
# service vncserver start
VNC サーバー を起動中: 1:root
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log

2:owner
New 'localhost.localdomain:2 (owner)' desktop is localhost.localdomain:2

Starting applications specified in /home/owner/.vnc/xstartup
Log file is /home/owner/.vnc/localhost.localdomain:2.log

                                                          [  OK  ]
#
ファイアウォール設定の追加
以下のポートに対し許可設定する
  • tcp/5901 <- "1:root"定義で設定されるポート
  • tcp/5902 <- "2:owner"定義で設定されるポート
VNCクライアントでの接続方法
それぞれ以下接続先を指定する
rootユーザへの接続
localhost.localdomain:1

ownerユーザへの接続
localhost.localdomain:2
参考
以上

コメント