Last active
November 27, 2024 15:31
-
-
Save supersonictw/14dc3cfc0c82b7c9cf430ad33d0a12da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# auto_x11vnc.sh | |
# SPDX-License-Identifier: MIT (https://ncurl.xyz/s/o_o6DVqIR) | |
# https://gist.github.com/supersonictw/14dc3cfc0c82b7c9cf430ad33d0a12da | |
SUDO='' | |
if [ "$EUID" != 0 ]; then | |
SUDO='sudo' | |
fi | |
VNC_PORT="5900" | |
VNC_PASSWORD_FILE="/etc/vncpasswd" | |
VNC_PASSWORD="$(cat /dev/urandom | head -n 1 | md5sum - | cut -d ' ' -f 1)" | |
$SUDO x11vnc -storepasswd "$VNC_PASSWORD" "$VNC_PASSWORD_FILE" | |
$SUDO tee "/lib/systemd/system/x11vnc.service" <<EOF | |
[Install] | |
WantedBy=graphical.target | |
[Unit] | |
Description=x11vnc Server | |
Wants=graphical.target | |
After=graphical.target | |
[Service] | |
Type=simple | |
Restart=always | |
ExecStart=$(which x11vnc) -auth guess -forever -loop -noxdamage -repeat -rfbauth $VNC_PASSWORD_FILE -rfbport $VNC_PORT -shared -display %i | |
EOF | |
echo "VNC Port: $VNC_PORT" | |
echo "VNC Password: $VNC_PASSWORD" | |
$SUDO systemctl daemon-reload | |
$SUDO systemctl enable --now "x11vnc.service" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment