-
Notifications
You must be signed in to change notification settings - Fork 970
Systemd unit for x0vncserver
Chris Horn edited this page Aug 1, 2022
·
11 revisions
To get autostart for x0vncserver
, you need to prepare a start script and a systemd unit.
Create a file with path /usr/local/bin/x0vnc.sh
.
#! /bin/bash
# Export an environment variable of the Display Manager
export XAUTHORITY="/var/run/lightdm/root/:0"
# Start VNC server for :0 display in background
## Set path to binary file
VNC_BIN=/usr/bin/x0vncserver
## Set parameters
## WARNING: This use of SecurityTypes is insecure.
## Anyone can connect to the VNC server without any authentication.
PARAMS="-display :0 -fg -SecurityTypes None"
## Launch VNC server
($VNC_BIN $PARAMS)
# Provide dirty exit code so that systemd
# will restart the server when a user logs out
exit 1
Create a file with path /etc/systemd/system/x0vncserver.service
.
[Unit]
Description=Remote desktop service (VNC) for :0 display
# Require start of
Requires=display-manager.service
# Wait for
After=network-online.target
After=display-manager.service
[Service]
Type=forking
# Set environment
Environment=HOME=/root
# Start command
ExecStart=/usr/local/bin/x0vnc.sh
# Restart service after session log out
Restart=on-failure
RestartSec=500ms
[Install]
WantedBy=multi-user.target
Give permissions for an execution
sudo chmod +x /usr/local/bin/x0vnc.sh
Launch the script
sudo /usr/local/bin/x0vnc.sh
Try to connect via VNC. No password is required.
sudo systemctl daemon-reload
sudo systemctl start x0vncserver.service
sudo systemctl status x0vncserver.service
sudo systemctl enable x0vncserver.service
sudo systemctl stop x0vncserver.service
sudo systemctl disable x0vncserver.service
The wiki is read-only because of malware spam that GitHub refuses to provide protection agains. Contact the maintainers directly with changes you'd like to make.