-
-
Save spinxz/1692ff042a7cfd17583b to your computer and use it in GitHub Desktop.
# Vncserver service file for Debian or Ubuntu with systemd | |
# | |
# Install vncserver and tools | |
# e.g. apt-get install tightvncserver autocutsel gksu | |
# | |
# 1. Copy this file to /etc/systemd/system/vncserver@:1.service | |
# 2. Edit User= | |
# e.g "User=paul" | |
# 3. Edit the vncserver parameters appropriately in the ExecStart= line! | |
# e.g. the -localhost option only allows connections from localhost (or via ssh tunnels) | |
# 4. Run `systemctl daemon-reload` | |
# 5. Run `systemctl enable vncserver@:<display>.service` | |
# | |
[Unit] | |
Description=Remote desktop service (VNC) | |
After=syslog.target network.target | |
[Service] | |
Type=forking | |
User=<user_name> | |
# Clean any existing files in /tmp/.X11-unix environment | |
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' | |
ExecStart=/usr/bin/vncserver -geometry 1800x1000 -depth 16 -dpi 120 -alwaysshared -localhost %i | |
ExecStop=/usr/bin/vncserver -kill %i | |
[Install] | |
WantedBy=multi-user.target |
#!/bin/sh | |
# vnc server xstartup file (~/.vnc/xstartup) for LXDE | |
# | |
# The sleeps seem to fix a bug where user input is not registered in vncviewer on client | |
# | |
# Fix to make GNOME work: | |
export XKL_XMODMAP_DISABLE=1 | |
# hack to allow sudo in vncviewer: | |
xhost +localhost | |
autocutsel -fork | |
sleep 2 | |
# unclear if the x-window-manager is needed: | |
x-window-manager & | |
sleep 2 | |
lxterminal & | |
sleep 2 | |
/usr/bin/lxsession -s LXDE -e LXDE & |
I am trying to use the file on Raspbian x86 in a virtual machine under VMware (whicn doesn't have RealVNC installed in the image, or for free). It seems like it's starting, but I can't connect to it. Here's the status, when I run vnc@:1.service:
`● vnc@:1.service - Remote desktop service (VNC)
Loaded: loaded (/lib/systemd/system/vnc@:1.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-10-29 21:22:38 CEST; 19s ago
Process: 4739 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
Process: 4747 ExecStart=/usr/bin/vncserver -geometry 1800x1000 -depth 16 -dpi 120 -alwaysshared -localhost :1 (code=exite>
Tasks: 49 (limit: 4614)
Memory: 64.0M
CPU: 3.981s
CGroup: /system.slice/system-vnc.slice/vnc@:1.service
├─4758 Xtightvnc :1 -desktop X -auth /home/pi/.Xauthority -geometry 1800x1000 -depth 16 -rfbwait 120000 -rfbauth>
├─4764 /bin/sh /home/pi/.vnc/xstartup
├─4767 /usr/bin/lxsession -s LXDE-pi -e LXDE
├─4780 dbus-launch --autolaunch 79becc19a60b43158ba55566836eef1e --binary-syntax --close-stderr
├─4781 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 --print-address 7 --session
├─4806 /usr/bin/dbus-launch --exit-with-session --sh-syntax
├─4807 /usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session
├─4828 /usr/bin/ssh-agent x-session-manager
├─4856 /usr/libexec/gvfsd
├─4861 /usr/libexec/gvfsd-fuse /home/pi/.cache/gvfs -f
├─4869 lxpolkit
├─4877 pcmanfm --desktop --profile LXDE-pi
├─4887 /usr/bin/ssh-agent -s
├─4901 /usr/bin/python3 /usr/share/system-config-printer/applet.py
├─4970 /usr/libexec/gvfs-udisks2-volume-monitor
├─4976 /usr/libexec/gvfs-mtp-volume-monitor
├─4984 /usr/libexec/gvfs-gphoto2-volume-monitor
├─4989 /usr/libexec/gvfs-goa-volume-monitor
├─4994 /usr/libexec/gvfs-afc-volume-monitor
├─5057 /usr/libexec/gvfsd-trash --spawner :1.2 /org/gtk/gvfs/exec_spaw/0
└─5384 /usr/lib/vmware-tools/sbin32/vmtoolsd -n vmusr --blockFd 3
okt. 29 21:22:39 raspberry dbus-daemon[4807]: [session uid=1000 pid=4805] Activating service name='org.gtk.vfs.UDisks2VolumeM>
okt. 29 21:22:40 raspberry dbus-daemon[4807]: [session uid=1000 pid=4805] Successfully activated service 'org.gtk.vfs.UDisks2>
okt. 29 21:22:40 raspberry dbus-daemon[4807]: [session uid=1000 pid=4805] Activating service name='org.gtk.vfs.MTPVolumeMonit>
`
Any Idea why I can't connect on 5900, 5901, 5800 or 5801?
Has anyone configured this with newer versions of tigervnc ? Tigervnc recommends that we need to put users in /etc/tigervnc/tigervnc.users
I understand, thank you. It seems like VNC isn't yet a plug&play technology... I can't find how to make VNC working through SSH on Ubuntu 20.04 that launch automatically on startup. Never mind, I'll give xrdp a try.