Skip to content

Instantly share code, notes, and snippets.

@lightrush
Created November 3, 2017 05:18
Show Gist options
  • Save lightrush/e6c3310fd0795b03f19daa40abf674e1 to your computer and use it in GitHub Desktop.
Save lightrush/e6c3310fd0795b03f19daa40abf674e1 to your computer and use it in GitHub Desktop.
X11vnc Systemd Unit File

X11vnc Systemd Unit File

This Systemd unit file starts X11VNC on boot

  1. Set VNC password: sudo x11vnc -storepasswd [YOUR VNC PASSWORD] /etc/x11vnc.passwd
  2. Install Systemd Unit File
sudo cp [path to]/vnc.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable vnc.service
[Unit]
Description=VNC Server
After=multi-user.target network.target
[Service]
Restart=always
# Replace this with x0vncserver from TigerVNC in Ubuntu 18.04.
# Set password by running `sudo x11vnc -storepasswd [PASSWORD] /etc/x11vnc.passwd`
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.passwd -rfbport 5900 -shared
[Install]
WantedBy=multi-user.target
@grayguest
Copy link

thank you

@tayyabmujahid
Copy link

@grayguest where would the vnc.service be located?

@aonoa
Copy link

aonoa commented Mar 8, 2021

@grayguest vnc.service将位于哪里?

/etc/systemd/system/

@hrkck
Copy link

hrkck commented Mar 16, 2021

Hello, I have a question about this systemd unit file.
From a client's terminal I run this command to connect to a server:
ssh -tL 5900:localhost:5900 DESKTOP_IP 'sudo x11vnc -usepw -auth guess -localhost -display :0'

This allows me to view the server with a vncviewer, both when this systemd unit file is active or not.

Is there anything wrong with my practice? It seems like for security, we should use an SSH connection, and since we send x11vnc -usepw ... command to the server, it does not make a difference whether this unit file is active or not.

I can also connect to the server with that ssh command on boot (the server boots up to a lightdm login and there is xfce4 as DM). This is my first time establishing a nicely working x11vnc server between my laptop and desktop, but I am still not sure how I did it...

@grayguest
Copy link

@grayguest where would the vnc.service be located?

/lib/systemd/system/ also ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment