AlmaLinux9 VNC サーバーの設定方法

環境
AlmaLinux release 9.2 (Turquoise Kodkod)

操作方法
1.VNC サーバーをインストールします。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# dnf -y install tigervnc-server
# dnf -y install tigervnc-server
# dnf -y install tigervnc-server

2.Firewalld を有効にしている場合は、VNC サービスを許可します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# firewall-cmd --add-service=vnc-server
# firewall-cmd --runtime-to-permanent
# firewall-cmd --add-service=vnc-server # firewall-cmd --runtime-to-permanent
# firewall-cmd --add-service=vnc-server
# firewall-cmd --runtime-to-permanent

3.SELinux を有効にしている場合は、ポリシーを変更します。
# vi vncsession.te
# 以下の内容で新規作成

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
module vncsession 1.0;
require {
type default_t;
type xdm_home_t;
type vnc_session_t;
class dir { add_name create write };
class file { create open write };
}
#============= vnc_session_t ==============
allow vnc_session_t default_t:dir { add_name write };
allow vnc_session_t default_t:file { create open write };
allow vnc_session_t xdm_home_t:dir create;
module vncsession 1.0; require { type default_t; type xdm_home_t; type vnc_session_t; class dir { add_name create write }; class file { create open write }; } #============= vnc_session_t ============== allow vnc_session_t default_t:dir { add_name write }; allow vnc_session_t default_t:file { create open write }; allow vnc_session_t xdm_home_t:dir create;
module vncsession 1.0;

require {
        type default_t;
        type xdm_home_t;
        type vnc_session_t;
        class dir { add_name create write };
        class file { create open write };
}

#============= vnc_session_t ==============
allow vnc_session_t default_t:dir { add_name write };
allow vnc_session_t default_t:file { create open write };
allow vnc_session_t xdm_home_t:dir create;

変更後ポリシーを反映します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# checkmodule -m -M -o vncsession.mod vncsession.te
# semodule_package --outfile vncsession.pp --module vncsession.mod
# semodule -i vncsession.pp
# checkmodule -m -M -o vncsession.mod vncsession.te # semodule_package --outfile vncsession.pp --module vncsession.mod # semodule -i vncsession.pp
# checkmodule -m -M -o vncsession.mod vncsession.te
# semodule_package --outfile vncsession.pp --module vncsession.mod
# semodule -i vncsession.pp

4.Tigervnc を Systemd Unit で起動する場合は以下のように設定します。
# VNC パスワード設定

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
$ vncpasswd Password: Verify: Would you like to enter a view-only password (y/n)? n
$ vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n

ディスプレイマネージャーを設定します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ vi ~/.vnc/config
# 新規作成
# session=(使用するディスプレイマネージャー)
# securitytypes=(セキュリティオプション)
# geometry=(画面のサイズ)
session=gnome
securitytypes=vncauth,tlsvnc
geometry=800x600
$ vi ~/.vnc/config # 新規作成 # session=(使用するディスプレイマネージャー) # securitytypes=(セキュリティオプション) # geometry=(画面のサイズ) session=gnome securitytypes=vncauth,tlsvnc geometry=800x600
$ vi ~/.vnc/config
# 新規作成
# session=(使用するディスプレイマネージャー)
# securitytypes=(セキュリティオプション)
# geometry=(画面のサイズ)
session=gnome
securitytypes=vncauth,tlsvnc
geometry=800x600

5.root 権限で VNC を利用する (ディスプレイ番号)=(ユーザー名) を定義して、Systemd Unit を起動します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# vi /etc/tigervnc/vncserver.users
# 最終行に追記
# 説明にある通り [:(ディスプレイ番号)=(ユーザー名)] と指定する
# ディスプレイ番号 1 は 5901 番ポートをリスンする
# ディスプレイ番号 n + 5900 = リスンするポート
# ディスプレイ番号 7 + 5900 = 5907 番ポートをリスン
#
# This file assigns users to specific VNC display numbers.
# The syntax is <display>=<username>. E.g.:
#
# :2=andrew
# :3=lisa
:1=alma
:2=redhat
# vi /etc/tigervnc/vncserver.users # 最終行に追記 # 説明にある通り [:(ディスプレイ番号)=(ユーザー名)] と指定する # ディスプレイ番号 1 は 5901 番ポートをリスンする # ディスプレイ番号 n + 5900 = リスンするポート # ディスプレイ番号 7 + 5900 = 5907 番ポートをリスン # # This file assigns users to specific VNC display numbers. # The syntax is <display>=<username>. E.g.: # # :2=andrew # :3=lisa :1=alma :2=redhat
# vi /etc/tigervnc/vncserver.users
# 最終行に追記
# 説明にある通り [:(ディスプレイ番号)=(ユーザー名)] と指定する
# ディスプレイ番号 1 は 5901 番ポートをリスンする
# ディスプレイ番号 n + 5900 = リスンするポート
# ディスプレイ番号 7 + 5900 = 5907 番ポートをリスン
#
# This file assigns users to specific VNC display numbers.
# The syntax is <display>=<username>. E.g.:
#
# :2=andrew
# :3=lisa
:1=alma
:2=redhat

# 設定したディスプレイ番号分起動する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# systemctl enable --now vncserver@:1 vncserver@:2
# systemctl enable --now vncserver@:1 vncserver@:2
# systemctl enable --now vncserver@:1 vncserver@:2

 

AlmaLinux 9

Posted by arkgame