TigerVNC服务器服务启动失败

TigerVNC服务器服务启动失败

尝试在 centos7 机器上安装 TigerVNC 进行远程桌面访问(以 root 身份),基于文章。具有以下配置

[root@HW01 ~]# cat /etc/systemd/system/vncserver@:1.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/[email protected]
# 2. Replace <USER> with the actual user name and edit vncserver
#    parameters appropriately
#    (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
#     PIDFile=/home/<USER>/.vnc/%H%i.pid)
# 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 root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

做过...

[root@HW01 ~]# vncpasswd
Password:
Password not changed
[root@HW01 ~]#

确认没有 root 密码,但出现以下错误...

[root@HW01 ~]# systemctl start vncserver@:1.service
Job for vncserver@:1.service failed because the control process exited with error code. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
[root@HW01 ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-07-19 16:03:11 HST; 14s ago
  Process: 72135 ExecStart=/usr/sbin/runuser -l root -c /usr/bin/vncserver %i (code=exited, status=1/FAILURE)
  Process: 72129 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)

Jul 19 16:03:11 HW01.ucera.local systemd[1]: Starting Remote desktop service (VNC)...
Jul 19 16:03:11 HW01.co.local runuser[72135]: Password:
Jul 19 16:03:11 HW01.co.local systemd[1]: vncserver@:1.service: control process exited, cod...s=1
Jul 19 16:03:11 HW01.co.local systemd[1]: Failed to start Remote desktop service (VNC).
Jul 19 16:03:11 HW01.co.local systemd[1]: Unit vncserver@:1.service entered failed state.
Jul 19 16:03:11 HW01.co.local systemd[1]: vncserver@:1.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

有人知道这里可能出了什么问题吗?有什么调试建议吗?

答案1

根据 RHEL7 上的帖子论坛和之前链接的文章一样,问题似乎是我没有为用户重置 vncpasswd(我之前故意没有这样做,因为想将密码保留为空(似乎这是不可能的,或者我误解了 vncpasswd 的实际作用))。所以这样做...

在此处输入图片描述

... 在启动服务之前阅读本文有助于解决问题。

[root@HW04 ~]# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
[root@HW04 ~]# systemctl start vncserver@:1.service
[root@HW04 ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Mon 2019-07-22 12:39:17 HST; 5min ago
  Process: 2170 ExecStop=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
  Process: 2125 ExecStart=/usr/sbin/runuser -l root -c /usr/bin/vncserver %i (code=exited, status=0/SUCCESS)
  Process: 2122 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 2143 (code=exited, status=0/SUCCESS)

Jul 22 12:39:09 HW04.co.local systemd[1]: Starting Remote desktop service (VNC)...
Jul 22 12:39:17 HW04.co.local systemd[1]: Started Remote desktop service (VNC).

相关内容