|
|
8aca67 |
# The vncserver service unit file
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# Quick HowTo: As the User wanting to have this functionality
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# 1. Copy this file to ~/.config/systemd/user/ (Optional, in case default settings are not suitable)
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# $ mkdir -p ~/.config/systemd/user
|
|
|
8aca67 |
# $ cp /usr/lib/systemd/user/vncserver@.service ~/.config/systemd/user/
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# 2. Reload user's systemd
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# $ systemctl --user daemon-reload
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# 3. Start the service immediately and enable it at boot
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# $ systemctl --user enable vncserver@:<display>.service --now
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# 4. Enable lingering
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# $ loginctl enable-linger
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# DO NOT RUN THIS SERVICE if your local area network is
|
|
|
8aca67 |
# untrusted! For a secure way of using VNC, you should
|
|
|
8aca67 |
# limit connections to the local host and then tunnel from
|
|
|
8aca67 |
# the machine you want to view VNC on (host A) to the machine
|
|
|
8aca67 |
# whose VNC output you want to view (host B)
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# this will open a connection on port 590N of your hostA to hostB's port 590M
|
|
|
8aca67 |
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
|
|
|
8aca67 |
# See the ssh man page for details on port forwarding)
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
|
|
|
8aca67 |
# the help of ssh, you end up seeing what hostB makes available on port 590M
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
|
|
|
8aca67 |
#
|
|
|
8aca67 |
# Use "-localhost" to prevent remote VNC clients connecting except when
|
|
|
8aca67 |
# doing so through a secure tunnel. See the "-via" option in the
|
|
|
8aca67 |
# `man vncviewer' manual page.
|
|
|
8aca67 |
|
|
|
8aca67 |
|
|
|
8aca67 |
[Unit]
|
|
|
8aca67 |
Description=Remote desktop service (VNC)
|
|
|
8aca67 |
After=syslog.target network.target
|
|
|
8aca67 |
|
|
|
8aca67 |
[Service]
|
|
|
8aca67 |
Type=forking
|
|
|
8aca67 |
|
|
|
8aca67 |
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
|
|
|
8aca67 |
ExecStart=/usr/bin/vncserver %i
|
|
|
8aca67 |
ExecStop=/usr/bin/vncserver -kill %i
|
|
|
8aca67 |
|
|
|
8aca67 |
Restart=on-success
|
|
|
8aca67 |
RestartSec=15
|
|
|
8aca67 |
|
|
|
8aca67 |
[Install]
|
|
|
8aca67 |
WantedBy=default.target
|