ConcurrentReal-Time-Logo

リアルタイムテクニカルドキュメント 最終更新 2024.03.12


[images/hand.right] RedHawk7.2.x TigerVNCの設定(HTML) 2024.03.12


[images/hand.right] RedHawk7.2.x TigerVNCの設定 2024.03.12

RedHawk7.2で確認した、TigerVNC動作確認の手順を下記に示します。

1.インストールモジュール
次のパッケージがインストールされていることを確認します。

# rpm -qa|grep tiger
tigervnc-server-1.3.1-3.el7.x86_64
tigervnc-license-1.3.1-3.el7.noarch
tigervnc-icons-1.3.1-3.el7.noarch
tigervnc-server-minimal-1.3.1-3.el7.x86_64
tigervnc-1.3.1-3.el7.x86_64

2.vncユーザ
この例では「vncuser1,vncuser2」がユーザ名です

# useradd -m vncuser1
# useradd -m vncuser2
# fgrep vncuser /etc/passwd
vncuser1:x:1000:1000::/home/vncuser1:/bin/bash
vncuser2:x:1001:1001::/home/vncuser2:/bin/bash

3.TigerVNCサーバ設定

3.1 /usr/lib/systemd/system/vncserver@.service ファイルをテンプレートとして、ユーザ分コピーし<USER>の部分をVNCユーザ名に変更します。

# cp /usr/lib/systemd/system/vncserver@.service  /usr/lib/systemd/system/vncserver_1@.service
# vi /usr/lib/systemd/system/vncserver_1@.service

編集前

# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@.service
# 2. Edit <USER> and vncserver parameters appropriately
#   ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# 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.

[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

編集後

# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@.service
# 2. Edit <USER> and vncserver parameters appropriately
#   ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# 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.

[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 vncuser1 -c "/usr/bin/vncserver %i"
PIDFile=/home/vncuser1/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target


3.2 上記作業をユーザ分行う
4.vncユーザのパスワード設定(「vncuser1」ユーザで実行します)

#  su - vncuser1
最終ログイン: 2024/03/11 (月) 12:43:31 JST日時 pts/1
[vncuser1@redhawk ~]$ vncpasswd Password:******** Verify:******** [vncuser1@redhawk ~]$ exit ログアウト
# su - vncuser2 :
5.vncサーバ起動と確認

# systemctl enable  vncserver_1@\:1
Created symlink from /etc/systemd/system/multi-user.target.wants/vncserver_1@:1.service to /usr/lib/systemd/system/vncserver_1@.service.
# systemctl start  vncserver_1@\:1
# systemctl status  vncserver_1@\:1
 vncserver_1@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver_1@.service; enabled; vendor preset: disabled)
   Active: active (running) since 火 2024-03-12 10:28:52 JST; 8s ago
  Process: 26818 ExecStart=/usr/sbin/runuser -l vncuser1 -c /usr/bin/vncserver %i (code=exited, status=0/SUCCESS)
  Process: 26814 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 26861 (Xvnc)
   CGroup: /system.slice/system-vncserver_1.slice/vncserver_1@:1.service
           ‣ 26861 /usr/bin/Xvnc :1 -desktop redhawk:1 (vncuser1) -auth /home/vncuser1/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /home/vncuser1/.vnc/passwd -rfbport 59...

 3月 12 10:28:49 redhawk systemd[1]: Starting Remote desktop service (VNC)...
 3月 12 10:28:52 redhawk systemd[1]: Started Remote desktop service (VNC).

6. vncポートがオープンしているかの確認
注:ポート番号は「5900+ディスプレイ番号」になり、5901からの利用になります。

# nmap IP_ADDRESS -p 5900-5999
Starting Nmap 6.40 ( http://nmap.org ) at 2024-03-12 10:31 JST
Nmap scan report for 172.18.3.11
Host is up (0.0000070s latency).
Not shown: 99 closed ports
PORT     STATE SERVICE
5901/tcp open  vnc-1

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds

# nmap localhost -p 5900-5999

Starting Nmap 6.40 ( http://nmap.org ) at 2024-03-12 10:31 JST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0000070s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 99 closed ports
PORT     STATE SERVICE
5901/tcp open  vnc-1

Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds

# /usr/sbin/runuser -l vncuser1 -c "vncserver -list"

TigerVNC server sessions:

X DISPLAY #	PROCESS ID
:1		26861


7. 追加処置
7.1 ログインした時、「カラープロファイルを作成しますには認証が必要です」 ダイアログを消す方法
/etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla というファイルを作り、以下のように設定する。

# cat /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla
[Allow Colord all Users]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile
ResultAny=no
ResultInactive=no
ResultActive=yes

7.2 ログインした時、"Authentication required to refresh system repositories" ダイアログを消す方法
/etc/polkit-1/localauthority/50-local.d/46-allow-update-repo.pkla というファイルを作り、以下のように設定する。

# cat /etc/polkit-1/localauthority/50-local.d/46-allow-update-repo.pkla
[Allow Package Management all Users]
Identity=unix-user:*
Action=org.freedesktop.packagekit.system-sources-refresh
ResultAny=yes
ResultInactive=yes
ResultActive=yes

7.3 ログインした時、"Authentication required to set the network proxy used for downloading software" ダイアログを消す方法
/etc/polkit-1/localauthority/30-site.d/20-no-show-proxy-dialog.pkla というファイルを作り、以下のように設定する。

# cat /etc/polkit-1/localauthority/30-site.d/20-no-show-proxy-dialog.pkla
[No Show Proxy Dialog]
Identity=unix-user:*
Action=org.freedesktop.packagekit.system-network-proxy-configure
ResultAny=no
ResultInactive=no
ResultActive=no

7.4 "Authentication required to access the PC/SC daemon" ダイアログを消す方法
以下のコマンドを実行する。

# systemctl stop pcscd.socket
# systemctl stop pcscd
# systemctl disable pcscd.socket
# systemctl disable pcscd.service

7.5 "Smart Card Manager" ダイアログを消す方法
/etc/xdg/autostart/esc.desktop を削除するか移動して、"Enterprise Security Client Smart Card Client"がログイン時に自動起動しないようにする。
以下のコマンドを実行する。

# mkdir /etc/xdg/autostart/SVAE
# mv /etc/xdg/autostart/esc.desktop /etc/xdg/autostart/SVAE

7.6 "Couldn't share keys Can't publish discovery information on the network" ダイアログを消す方法
以下のコマンドでパッケージを削除する。

# yum remove seahorse-sharing
	:
依存性を解決しました

================================================================================
 Package                アーキテクチャー
                                     バージョン           リポジトリー     容量
================================================================================
削除中:
 seahorse-sharing       x86_64       3.8.0-3.el7          installed       136 k

トランザクションの要約
================================================================================
削除  1 パッケージ

インストール容量: 136 k
上記の処理を行います。よろしいでしょうか? [y/N]y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  削除中                  : seahorse-sharing-3.8.0-3.el7.x86_64             1/1 
  検証中                  : seahorse-sharing-3.8.0-3.el7.x86_64             1/1 

削除しました:
  seahorse-sharing.x86_64 0:3.8.0-3.el7                                         

完了しました!

8.起動試験例
注意:ログイン名が同じものを複数起動した場合、同一セッションを同時に別ウィンドウで操作する事になります。


8.1 vncuser1ユーザでログインする例

# vncviewer -passwd /home/vncuser1/.vnc/passwd --shared localhost:1 &

TigerVNC Viewer 64-bit v1.3.1 (20151120)
Built on Nov 20 2015 at 20:47:44
Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.

Tue Mar 12 09:16:06 2024
 CConn:       connected to host localhost port 5901
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
 PlatformPixelBuffer: Using default colormap and visual, TrueColor, depth 24.
 CConn:       Using pixel format depth 24 (32bpp) little-endian rgb888
 CConn:       Using Tight encoding
 CConn:       Enabling continuous updates

[72vncuser1.png]

8.2 デスクトップユーザ(root)でログインする例

# vncserver :2

New 'redhawk:2 (root)' desktop is redhawk:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/redhawk:2.log

# vncserver -list

TigerVNC server sessions:

X DISPLAY #	PROCESS ID
:2		29858

# vncviewer -passwd ~/.vnc/passwd --shared localhost:2 &

TigerVNC Viewer 64-bit v1.3.1 (20151120)
Built on Nov 20 2015 at 20:47:44
Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.

Tue Mar 12 11:07:17 2024
 CConn:       connected to host localhost port 5902
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
 PlatformPixelBuffer: Using default colormap and visual, TrueColor, depth 24.
 CConn:       Using pixel format depth 24 (32bpp) little-endian rgb888
 CConn:       Using Tight encoding
 CConn:       Enabling continuous updates
 Viewport:    Unexpected release of FLTK key code 65293 (0xff0d)

[72vncuser1androot.png]

9.vncserverの停止。
9.1 下記の様に、vncserverコマンドで、確認の上停止します。
この時、vncuser1の利用している:1はユーザIDが異るため出力されません。

# vncserver -list

TigerVNC server sessions:

X DISPLAY #	PROCESS ID
:2		29858

# vncserver -list

TigerVNC server sessions:

X DISPLAY #	PROCESS ID
:2		19229
# vncserver -kill :2
Killing Xvnc process ID 19229

Tue Mar 12 12:57:08 2024
 CConn:       read: 接続が相手からリセットされました (104)

9.2 vncuser1の利用している:1を終了するには、下記のように、runuserコマンドを介して実行します。

# runuser -l vncuser1 -c "vncserver -list"

TigerVNC server sessions:

X DISPLAY #	PROCESS ID
:1		7240

# runuser -l vncuser1 -c "vncserver -kill :1"
Killing Xvnc process ID 7240
# runuser -l vncuser1 -c "vncserver -list"

TigerVNC server sessions:

X DISPLAY #	PROCESS ID

10. ユーザ個別のサーバー設定ファイル

ユーザ個別の設定は、~/.vnc/xstartupに記述します。

10.1 ユーザ個別のサーバー設定ファイル例
下記に、「Motif ウィンドウマネージャ」を利用する例を示します。(別途、dnf install motif を実行しておいて下さい)

(1) 下記の内容で、~/.vnc/xstartup ファイルを修正します。

変更前の~/.vnc/xstartup ファイル

#!/bin/sh
#  ~/.vnc/xstartup

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec /etc/X11/xinit/xinitrc

変更後の~/.vnc/xstartup ファイル

#!/bin/sh
#  ~/.vnc/xstartup

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

# オリジナル
#exec /etc/X11/xinit/xinitrc
#
xsetroot -solid gray20
####################################################
# 以下の記述はかな漢字変換を利用する場合に必要です
####################################################
export LANG=ja_JP.UTF-8
export GDM_LANG=ja_JP.UTF-8
####################################################
# 仮想モードでは、['+space']による、かな漢字変換エンジンへの切り替えが、
# ホスト側のウィンドウマネージャによって、アクセプトされ、仮想モード側に認識されないため、
# 別のキーバイディングに変更します。
####################################################
gsettings set org.freedesktop.ibus.general.hotkey trigger "['+space', 'Zenkaku_Hankaku', 'Alt+Kanji', 'Alt+grave', 'Hangul', 'Alt+Release+Alt_R']"
gsettings set org.freedesktop.ibus.general.hotkey triggers "['space']"
####################################################
# かな漢字変換エンジンを起動します
####################################################
/usr/bin/ibus-daemon -r --xim -d
/usr/libexec/ibus-engine-kkc --ibus &
/usr/libexec/ibus-engine-simple &
####################################################
# mwm ウィンドウマネージャを起動します
####################################################
/usr/bin/gnome-terminal
exec /usr/bin/mwm


(2)~/.vnc/xstartup ファイルに実行権を付与します。

# chmod 755 ~/.vnc/xstartup

(3) Motif起動画面

下記の様に、仮想vncサーバ上でMotif/xterm/かな漢字変換も動作します。

[TigerVNCmwm.png]


[back]Back