具有多个用户的 VNC 服务器

具有多个用户的 VNC 服务器

我为每个用户分配了一个 VNC 端口,但是启动服务时出现以下错误:

root@kensa-dev-server1:~# systemctl start [email protected]
Job for [email protected] failed because the control process exited with error code.
See "systemctl status [email protected]" and "journalctl -xe" for details.

root@kensa-dev-server1:~# journalctl -xe
-- Unit session-321.scope has finished starting up.
--
-- The start-up result is RESULT.
Jul 14 20:45:27 kensa-dev-server1 vncserver[6068]: Can't tell if 2 is on kensa-dev-server1
Jul 14 20:45:27 kensa-dev-server1 vncserver[6068]: Use -kill :<number> instead
Jul 14 20:45:27 kensa-dev-server1 systemd[6069]: pam_unix(login:session): session closed for user charlie
Jul 14 20:45:27 kensa-dev-server1 dbus-daemon[614]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.26032" (uid=1000 pid=6069 c
Jul 14 20:45:27 kensa-dev-server1 systemd[6069]: pam_systemd(login:session): Failed to release session: Access denied
Jul 14 20:45:27 kensa-dev-server1 systemd[6073]: pam_unix(login:session): session opened for user charlie by (uid=0)
Jul 14 20:45:27 kensa-dev-server1 systemd[1]: Started Session 322 of user charlie.
-- Subject: Unit session-322.scope has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit session-322.scope has finished starting up.
--
-- The start-up result is RESULT.
Jul 14 20:45:27 kensa-dev-server1 vncserver[6073]: Warning: kensa-dev-server1:2 is taken because of /tmp/.X11-unix/X2
Jul 14 20:45:27 kensa-dev-server1 vncserver[6073]: Remove this file if there is no X server kensa-dev-server1:2
Jul 14 20:45:27 kensa-dev-server1 vncserver[6073]: A VNC server is already running as :2
Jul 14 20:45:27 kensa-dev-server1 systemd[1]: [email protected]: Control process exited, code=exited status=2
Jul 14 20:45:27 kensa-dev-server1 systemd[1]: [email protected]: Failed with result 'exit-code'.
Jul 14 20:45:27 kensa-dev-server1 systemd[6074]: pam_unix(login:session): session closed for user charlie
Jul 14 20:45:27 kensa-dev-server1 systemd[1]: Failed to start Remote desktop service (VNC).
-- Subject: Unit [email protected] has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit [email protected] has failed.
--
-- The result is RESULT.
Jul 14 20:45:27 kensa-dev-server1 dbus-daemon[614]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.26034" (uid=1000 pid=6074 c
Jul 14 20:45:27 kensa-dev-server1 systemd[6074]: pam_systemd(login:session): Failed to release session: Access denied
Jul 14 20:45:29 kensa-dev-server1 systemd[1]: Reloading.

每个用户的服务单元文件:

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
#Type=simple
User=charlie
PAMName=login
PIDFile=/home/charlie/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill %i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
#ExecStart=/usr/sbin/runuser -l charlie -c "/usr/bin/vncserver -depth 24 -geometry 1280x800   %i"
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

只有 root 帐户才能启动 VNC 服务。

相关内容