CentOS(RHEL)でのVNCサーバ(GNOME対応)の設定方法
※viのところは青字部分が修正・追記部分です
※例はrootユーザを許可していますが、無論、非rootユーザを推奨します(真ん中より下にある方法参照)
VNCサーバの設定をする
※display番号を1に設定します
# 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="2:myusername" # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd"
VNCの接続パスワードの設定をする
# vncpasswd
※各ユーザを設定したい場合は su - ○○ をしてからvncpasswdを走らせる
一度vncサーバを起動する
# /etc/rc.d/init.d/vncserver start
※この状態でvnc接続をするとGNOMEではなく、Window Manager (twm)になってしまいます。(凄くシンプルです)
何事もなかったかのように一度vncサーバを停止する
# /etc/rc.d/init.d/vncserver stop
設定するユーザのホームディレクトリ配下に有る、各ユーザvncサーバ設定ファイルを編集します。
※rootの場合は以下のとおりですが、普段は/home/ユーザ名/.vnc/xstartup になります
# vi ~/.vnc/xstartup #!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc 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 &
再度vncサーバを起動する
# /etc/rc.d/init.d/vncserver start
VNCクライアントから接続します
※接続は○.○.○.○:1 になります(○.○.○.○にはIPアドレスが入ります)
VNCクライアントはREAL VNC(日本語版)等を利用ください
念のため、非rootユーザ用のvncserver設定
基本的にrootユーザ(上記)と同じです
VNCサーバの設定をする
※今回は、display番号を2に設定します
# 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="2:myusername" # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" VNCSERVERS="2:test" VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -nohttpd"
testユーザにスイッチします
# su - test
VNCの接続パスワードの設定をする
$ vncpasswd
rootに戻ります
$ exit
一度vncサーバを起動する
# /etc/rc.d/init.d/vncserver start
※この状態でvnc接続をするとGNOMEではなく、Window Manager (twm)になってしまいます。(凄くシンプルです)
何事もなかったかのように一度vncサーバを停止する
# /etc/rc.d/init.d/vncserver stop
設定するユーザのホームディレクトリ配下に有る、各ユーザvncサーバ設定ファイルを編集します。
※testユーザのhomeディレクトリは /home/test/ と仮定します。
# vi /home/test/.vnc/xstartup #!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc 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 &
再度vncサーバを起動する
# /etc/rc.d/init.d/vncserver start
VNCクライアントから接続します
※接続は○.○.○.○:2 になります(○.○.○.○にはIPアドレスが入ります)
以上の手順でVNCクライアントからdisplay番号2指定で繋がります。
複数ユーザ使用時のvncserver設定
基本的に同じです。/etc/sysconfig/vncserversが変わるだけです
# 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="2:myusername" # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" VNCSERVERS="1:root 2:test" VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd" VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -nohttpd"
ここから下は脱線。
個人的にび~ぼ自身は、VNC数度しか繋げたことがないです。
と、言うのもサーバ自体GUI使う必要も余り無いし(時々必要になる時がある)
【/etc/inittab】も【id:3:initdefault:】としてランレベル3で走らせてるし、
管理するならコマンド叩いたほうが早いかなと思います。
(コマンドを覚えちゃいましょう。)
GUI使わないといけないアプリとかインストーラの時用かなと。
例えばOracleとかその手。
画面呼ぶだけならXming(Xming日本語化プロジェクト)使ったらいいかなとも思えたり。
(Oracleは文字化けして使えませんでした。まぁ、lang=Cやれば良いんだけどね)
Xmingも今後若干書こうかな。