http://www.atmarkit.co.jp/flinux/rensai/linuxtips/877fc5devncserver.html !!!準備 !!インストール # yum install vnc ←クライアントのみ # yum install vnc-server ←サーバのみ # yum install vnc vnc-server ←サーバとクライアントの両方 または、 yum install tigervnc-server ubuntuの場合は tigervnc-standalone-server !!クライアント realvncかtigervncがいい。 !macのクライアント https://www.realvnc.com/en/connect/download/viewer/macos/ http://tigervnc.bphinz.com/nightly/ http://tigervnc.bphinz.com/nightly/osx/TigerVNC-1.10.80.dmg !!!設定 !!設定ファイルの編集 /etc/sysconfig/vncservers を編集して設定を行う。 !VNCSERVERS VNCSERVERS="ディスプレイ番号:ユーザーアカウント" 複数ユーザを指定するには      ↓ VNCSERVERS="1:nori 2:foo" !VNXSERVERARGS vncserverのオプションを指定する。 「-localhost」オプションを設定するとVNCサーバへのアクセスがlocalhostに限定されるので、外から接続する場合は削除する。 VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -nohttpd" VNCSERVERARGS[数字]の数字は、ディスプレイ番号を表す。 なので、ディスプレイ番号やユーザごとに解像度を変更したりすることができる。 VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd" VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd" など。 :-geometry 1680x1050:画面のサイズを「1680x1050」にする。 :-nolisten tcp:TCP経由でVNCサーバーにアクセスすることを禁止。らしい。意味がわからない。 :-nohttpd:WebベースでのVNCクライアントをサポートしない。 :-localhost:リモート接続のうち、セキュアトンネルを利用してないものを禁止。 !!VNC用パスワードの設定 vncpasswdコマンドでvncのパスワードを設定する。この操作は、各ユーザーで行う。 !!サービスを起動する /etc/init.d/vncserver start !!ウィンドウマネージャの設定 !gnome を利用する ~/.vnc/xstartup を # xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & gnome-session & のように変更する。 !!!接続 VNCクライアントでIPとディスプレイ番号を指定して接続 IP:ディスプレイ番号 で接続。 192.168.1.1:2 とか。 !!!サービス以外の方法で開始、終了 起動は vncserver。 停止は vncserver -kill :1 <- ディスプレイ番号 !!!Ubuntu で マルチユーザの vncサーバを起動する !!VNCのインストール http://usamantaray.blogspot.com/2008/10/setup-vnc-server-for-multiuser-in.html # apt-get install vnc4server # apt-get install vncviewer # mkdir -p /etc/sysconfig !!vncservers ファイルの作成と編集 /etc/sysconfig/vncservers を作成し、以下のように編集する。 # The VNCSERVERS variable is a list of display:user pairs. # # Uncomment the line below to start a VNC server on display :1 # 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 # . # VNCSERVERS="1:myusername" # VNCSERVERARGS[1]="-geometry 800x600" VNCSERVERS="1:user1 2:user2 3:user3 4:user4" VNCSERVERARGS[1]="-geometry 1280x992 -depth 16" VNCSERVERARGS[2]="-geometry 1280x1024" VNCSERVERARGS[4]="-geometry 1280x1024" VNCSERVERARGS[5]="-geometry 1280x1024" VNCSERVERARGS[6]="-geometry 1280x1024" VNCSERVERARGS[7]="-geometry 1280x1024" VNCSERVERARGS[20]="-geometry 1024x720" !!サービスの登録 /etc/init.d/vncserver を作成し、以下のように編集 #!/bin/bash # # chkconfig: - 91 35 # description: Starts and stops vncserver. \ # used to provide remote X administration services. # Source function library. # . /etc/init.d/functions # Source networking configuration. # . /etc/sysconfig/network # Check that networking is up. # [ ${NETWORKING} = "no" ] && exit 0 unset VNCSERVERARGS VNCSERVERS="" [ -f /etc/sysconfig/vncservers ] && . /etc/sysconfig/vncservers prog=$"VNC server" start() { REQ_USER=$2 echo -n $"Starting $prog: " ulimit -S -c 0 >/dev/null 2>&1 RETVAL=0 for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV DISP="${display%%:*}" export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}" su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}" fi done } stop() { REQ_USER=$2 echo -n $"Shutting down $prog: " for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV export USER="${display##*:}" su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1 fi done "\n" echo "Vncserver Stopped" } # See how we were called. case "$1" in start) start $@ ;; stop) stop $@ ;; restart|reload) stop $@ sleep 3 start $@ ;; condrestart) if [ -f /var/lock/subsys/vncserver ]; then stop $@ sleep 3 start $@ fi ;; status) status Xvnc ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 1 esac パーミッションを変更 # chmod a+x /etc/init.d/vncserver !!サービスの開始と終了 /etc/init.d/vncserver start /etc/init.d/vncserver stop !!ユーザ設定ファイルを編集 必要に応じて vi ~/.vnc/xstartup を編集。 !~/.vnc/xstartup #!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc unset DBUS_SESSION_BUS_ADDRESS [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey # vncconfig -iconic & vncconfig -nowin & vncconfig -set SendPrimary=0 & vncconfig -set SetPrimary=0 & # x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & # x-window-manager & mate-session & {{category2 OS,Linux}}