Skip to content

Instantly share code, notes, and snippets.

@mreschke
Last active April 7, 2016 14:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mreschke/005f2b8e01ceb3ed25e62d694b7e1239 to your computer and use it in GitHub Desktop.
Start x11vnc server at KDM or GDM starup using systemd
#!/bin/bash
# This is run from /etc/systemd/system/x11vnc.service
# This is run at KDM, not when user logs in, therefore the systemd
# unit is running as root user
# mReschke 2016-04-07
# Systemd unit file:
# ---------------------------------------------------
#[Unit]
#Description=VNC Server for X11
#[Service]
#Type=forking
#User=root
#ExecStart=/usr/local/bin/x11vnc-server
#Restart=on-failure
#[Install]
#WantedBy=multi-user.target
# ---------------------------------------------------
# To create/change your password file, run
# x11vnc -storepasswd yourPassHere /etc/x11vnc.pass
# Find the MIT-MAGIC-COOKIE file
# This works! But you can now just use -auth guess to find it automatically
#cookieFile=$(ps aux | grep -iv grep | grep '/var/run/xauth/A' | sed -n -e 's/.*\/var/\/var/p')
#echo "Running x11vnc with cookieFile: $cookieFile" >> /tmp/x11vnc-server.alive
# Start x11vnc
/usr/bin/x11vnc \
-norc \
-forever \
-shared \
-bg \
-rfbauth /etc/x11vnc.pass \
-autoport 5900 \
-o /var/log/x11vnc.log \
-display :0 \
-auth guess
# -auth $cookieFile
# From x11vnc notes
# ---------------------------------------------------
#** If NO ONE is logged into an X session yet, but there is a greeter login
# program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
# to find and use the raw display manager MIT-MAGIC-COOKIE file.
# Some examples for various display managers:
#
# gdm: -auth /var/gdm/:0.Xauth
# -auth /var/lib/gdm/:0.Xauth
# kdm: -auth /var/lib/kdm/A:0-crWk72
# -auth /var/run/xauth/A:0-crWk72
# xdm: -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
# dtlogin: -auth /var/dt/A:0-UgaaXa
#
# Sometimes the command "ps wwwwaux | grep auth" can reveal the file location.
#
# Starting with x11vnc 0.9.9 you can have it try to guess by using:
#
# -auth guess
#
# (see also the x11vnc -findauth option.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment