Difficulty: ★★☆☆☆
This topic is a rewrite of the solution to ANY vnc server in kde with sddm - credit to @bedna for the original solution.
VNC
VNC is a protocol where you use your keyboard/mouse/screen to monitor or control a remote system.
VNC is per definition insecure
Opening a VNC service onto insecure networks like the internet, public libraries, internet cafès etc. may lead to information leaking and/or attempts to take control of your system.
It is highly recommended to only expose VNC to the localhost and connect using a secure connection using SSH or VPN.
TigerVNC Limitations
Multiple X sessions for a single user are not supported
– TigerVNC - ArchWiki
This effectively means - if you are logged onto the physical display :0
then you cannot connect a vnc session. If you try to do so, using the same username, a black screen or system lockup will be the likely result.
In that regard it works like Microsoft RDP which logout the physical session when you initiate a remote connection and vice-versa.
The goal
Our goal is to connect to the physical display :0
using VNC.
Considerations
The remote system will act like a string puppet - you will be able to watch what happens on the remote system and so will anyone else knowing the password or - in case of an attached, powered-on monitor - watching the screen or display.
It will not be possible to share clipboard between systems.
The system to be controlled
On the system to be controlled install package tigervnc
and switch to root context
su -l root
VNC password
Create a password for the root user
vncpasswd
System service definition
Create a new service definition - the link uses LightDM as example
LightDM is used for the example below, but it should be possible to adapt it to other display managers by modifying the
XAUTHORITY
variable.
– TigerVNC - ArchWiki
This example uses SDDM - edit the file, paste below content and save.
touch /etc/systemd/system/x0vncserver.service
[Unit]
Description=Remote desktop service (VNC) for :0 display SDDM
Requires=display-manager.service
After=syslog.target network-online.target display-manager.service
[Service]
Type=simple
# This is for SDDM only
# - as sddm uses a random name for the XAUTHORITY file
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment XAUTHORITY=$(find /var/run/sddm/ -type f)"
Environment=HOME=/root
ExecStart=x0vncserver -display :0 -rfbauth /root/.vnc/passwd
Restart=on-failure
RestartSec=500ms
[Install]
WantedBy=multi-user.target
Enable and start the service
systemctl enable --now x0vncserver.service
Controlling system
Install the package tigervnc
and connect
vncviewer ip.x.y.z:5900
Conclusion
Be prepared for weird issues …
For one - after a period of inactivity - the vnc provided view may stop responding - only displaying background or black screen.
While watching the remote screen I was able to activate the password prompt and input the password - yet the vncviewer remainded black with only the mousepointer visible and still controlling the remote as could be seen on the attached monitor.
Connecting directly to screen :0
may seem the way to go if you want to the display manager directly but poses other challenges.
Perhaps you are better of using the configuration outlined in these topics