Skip to content

Instantly share code, notes, and snippets.

@acarapetis
Last active July 11, 2024 01:05
Show Gist options
  • Save acarapetis/72349da760d9efefc636ec0d0c04ca27 to your computer and use it in GitHub Desktop.
Save acarapetis/72349da760d9efefc636ec0d0c04ca27 to your computer and use it in GitHub Desktop.
Simple local VNC setup [NO SECURITY]
#!/bin/bash
# ~/.xsession
systemctl --user import-environment DISPLAY XAUTHORITY
systemctl --user restart xdg-desktop-portal-gtk
i3
# /etc/lightdm/lightdm.conf.d/99-my-vnc.conf
[LightDM]
start-default-seat=false # don't start on the "physical" display, only on XDMCP
[SeatDefaults]
autologin-user=anthony
autologin-user-timeout=0
greeter-hide-users=true
user-session=i3
[XDMCPServer]
enabled=true
  • install deps and configure lightdm as the default display manager:

    • apt-get install lightdm tigervnc-standalone-server
    • dpkg-reconfigure lightdm # and choose lightdm from the list
  • install gist files in the locations noted

  • configure systemd to launch it automatically:

    • systemctl daemon-reload && systemctl enable my-vnc
    • systemctl set-default graphical.target
  • start it now for the first time:

    • systemctl start graphical.target
    • systemctl start my-vnc

I do sometimes find things are broken on the first login after a reboot - a sudo systemctl restart my-vnc fixes it. Probably missing some dependencies in After=.

# /etc/systemd/system/my-vnc.service
[Unit]
Description=Persistent VNC seat
After=network.target display-manager.service
[Service]
Type=simple
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=0
StartLimitInterval=10
# -SecurityTypes None disables VNC auth - this is handled further up the stack.
# -query localhost tells Xvnc to connect to XDMCP at localhost:177.
ExecStart=Xvnc -SecurityTypes None -query localhost -rfbport 5901 :1
User=anthony
KillMode=mixed
[Install]
WantedBy=graphical.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment