Windows PCからvncで接続するためにCentOS 7にvnc serverをインストールしてみました。
サポート>製品マニュアル>Red Hat Enterprise Linux>7システム管理者のガイド>第8章 TIGERVNC
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-TigerVNC.html
ここに記載されていることをそのまま作業すれば何の問題も無かったのに、ここにたどり着くまでネット徘徊で時間を浪費してました”^^;
Red Hat Enterprise Linux 7,CentOS 7はまずここを確認ですね。
サポート>製品マニュアル>Red Hat Enterprise Linux>7システム管理者のガイド
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/part-Basic_System_Configuration.html
- vnc server install
 - config file copy
 - config file edit
 - 設定の反映
 - パスワード設定
 - vncサーバ起動
 - 自動起動設定
 
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62  | 
						[root@host01 ~]# yum info tigervnc-server Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile  * base: ftp.iij.ad.jp  * epel: ftp.jaist.ac.jp  * extras: ftp.iij.ad.jp  * updates: ftp.iij.ad.jp Available Packages Name        : tigervnc-server Arch        : x86_64 Version     : 1.3.1 Release     : 3.el7 Size        : 202 k Repo        : base/7/x86_64 Summary     : A TigerVNC server URL         : http://www.tigervnc.com License     : GPLv2+ Description : The VNC system allows you to access the same desktop from a wide             : variety of platforms.  This package includes set of utilities             : which make usage of TigerVNC server more user friendly. It also             : contains x0vncserver program which can export your active             : X session. [root@host01 ~]# yum -y install tigervnc-server Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile  * base: ftp.iij.ad.jp  * epel: ftp.jaist.ac.jp  * extras: ftp.iij.ad.jp  * updates: ftp.iij.ad.jp Resolving Dependencies --> Running transaction check ---> Package tigervnc-server.x86_64 0:1.3.1-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ===========================================================================================================  Package                        Arch                  Version                    Repository           Size =========================================================================================================== Installing:  tigervnc-server                x86_64                1.3.1-3.el7                base                202 k Transaction Summary =========================================================================================================== Install  1 Package Total download size: 202 k Installed size: 493 k Downloading packages: tigervnc-server-1.3.1-3.el7.x86_64.rpm                                              | 202 kB  00:00:02 Running transaction check Running transaction test Transaction test succeeded Running transaction   Installing : tigervnc-server-1.3.1-3.el7.x86_64                                                      1/1   Verifying  : tigervnc-server-1.3.1-3.el7.x86_64                                                      1/1 Installed:   tigervnc-server.x86_64 0:1.3.1-3.el7 Complete!  | 
					
今回はユーザごとの利用を想定して設定ファイルを作成します。
| 
					 1  | 
						[root@host01 ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-matsuoka@.service  | 
					
config fileにUserIDを設定します。
【default】
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14  | 
						[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i" PIDFile=/home/<USER>/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target  | 
					
<USER>をUserIDに変更します。
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14  | 
						[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/usr/sbin/runuser -l matsuoka -c "/usr/bin/vncserver %i" PIDFile=/home/matsuoka/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target  | 
					
| 
					 1  | 
						[root@host01 ~]# systemctl daemon-reload  | 
					
実はこのコマンドを実行する前に確認したらすでに反映されていたのですが、念の為にってことでガイドにそって実行しておきました。
| 
					 1 2  | 
						[root@host01 ~]# systemctl list-unit-files | grep vnc vncserver-matsuoka@.service                 disabled  | 
					
ユーザになってパスワードを設定します。
実際にはユーザ自身に設定してもらうことになると思いますが。
| 
					 1 2 3 4 5 6  | 
						[root@host01 ~]# su - matsuoka Last login: Mon Feb 22 15:33:29 JST 2016 on tty1 [matsuoka@host01 ~]$ vncpasswd Password: Verify: [matsuoka@host01 ~]$ exit  | 
					
パスワードファイルは下記に作成されます。
| 
					 1 2 3 4  | 
						[root@host01 ~]# ll ~matsuoka/.vnc/passwd -rw-------. 1 matsuoka matsuoka 8 Feb 22 16:57 /home/matsuoka/.vnc/passwd [root@host01 ~]# file ~matsuoka/.vnc/passwd /home/matsuoka/.vnc/passwd: data  | 
					
今回はディスプレイ:1で起動します。接続ポートは5901になります。
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13  | 
						[root@host01 ~]# systemctl start vncserver-matsuoka@:1.service [root@host01 ~]# systemctl status vncserver-matsuoka@:1.service * vncserver-matsuoka@:1.service - Remote desktop service (VNC)    Loaded: loaded (/etc/systemd/system/vncserver-matsuoka@.service; disabled; vendor preset: disabled)    Active: active (running) since Mon 2016-02-22 17:00:08 JST; 12s ago   Process: 16360 ExecStart=/usr/sbin/runuser -l matsuoka -c /usr/bin/vncserver %i (code=exited, status=0/SU               CCESS)   Process: 16357 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, st               atus=0/SUCCESS)  Main PID: 16385 (Xvnc)    CGroup: /system.slice/system-vncserver\x2dmatsuoka.slice/vncserver-matsuoka@:1.service            > 16385 /usr/bin/Xvnc :1 -desktop host01.rootlinks.net:1 (matsuoka) -auth /home/matsuoka/.Xau... Feb 22 17:00:05 host01.rootlinks.net systemd[1]: Starting Remote desktop service (VNC)... Feb 22 17:00:08 host01.rootlinks.net systemd[1]: Started Remote desktop service (VNC).  | 
					
サーバ起動時に自動起動していつでもvnc接続が出来るようにします。
| 
					 1  | 
						[root@host01 ~]# systemctl enable vncserver-matsuoka@:1.service  | 
					
これで端末からvnc接続できるようになったはずです。
次回は実際に接続してみます。
ちなみにvncサーバの停止は
| 
					 1  | 
						[root@host01 ~]# systemctl stop vncserver-matsuoka@:1.service  | 
					
自動起動の停止は
| 
					 1  | 
						[root@host01 ~]# systemctl disable vncserver-matsuoka@:1.service  | 
					
になります。