■CentOS7での作業
TigerVNCのインストール
# yum groups install "GNOME Desktop"
# yum install tigervnc-server
パスワード設定
# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
ファイアウォール(firewalld)にてVNC通信を許可
(今回は自身のPCの隣のPCなのでファイアウォールなしの環境ですが。。必要な方は下記で。)
# firewall-cmd --permanent --add-port=5901/tcp
# firewall-cmd --reload
# firewall-cmd --list-all
VNCの起動確認
# vncserver :1
xauth: file /root/.Xauthority does not exist
New 'nisshi.local:1 (root)' desktop is nisshi.local:1
Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/nisshi.local:1.log
起動確認
# vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:1 25178
# ss -nlpt | grep vnc
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 *:5901 *:* users:(("Xvnc",pid=25178,fd=9))
LISTEN 0 128 *:6001 *:* users:(("Xvnc",pid=25178,fd=6))
LISTEN 0 5 :::5901 :::* users:(("Xvnc",pid=25178,fd=10))
LISTEN 0 128 :::6001 :::* users:(("Xvnc",pid=25178,fd=5))
■Windows10での作業
UltraVNCのインストール
UltraVNC Viewerのみをインストールする。
1)起動後は、”VNC Server:”に 接続先IP:VNCポート番号を入力
2)”Connect”を押下
3)パスワードを聞いてくるので入力して”Log On”を押下
■CentOS7での作業
問題なく確認が終われば、一時起動させていたプロセスを停止させる
# vncserver -kill :1
Killing Xvnc process ID 25178
# vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
# ss -nlpt | grep vnc
State Recv-Q Send-Q Local Address:Port Peer Address:Port
VNCの自動起動化
サービスとして登録し、OS起動時に自動的に起動するようにする。
# cp -p /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
# vi /etc/systemd/system/vncserver@:1.service
# diff /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
39a40,41
> User=root
> PAMName=login
43,44c45,48
< ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
< PIDFile=/home/<USER>/.vnc/%H%i.pid
---
> #ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
> ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
> #PIDFile=/home/<USER>/.vnc/%H%i.pid
> PIDFile=/root/.vnc/%H%i.pid
# systemctl daemon-reload
# systemctl start vncserver@:1.service
# systemctl enable vncserver@:1.service
VNCサーバログイン時の解像度を変更する
# vim /root/.vnc/config
geometry=1280x800
# systemctl restart vncserver@:1.service