You are not logged in.
By starting the VNC server "x11vnc" as a service on boot, you can control the PC remotely, even if no one has logged in yet.
Make sure you research VNC's security risks and confirm that it's safe to use VNC on your network. I'm using VNC on my home LAN with no other users and no wifi access points, so I concentrated primarily on getting the VNC server to work, with a minimum amount of security (VNC password only).
I tested these instructions on Devuan Daedalus and Devuan Jessie with a fresh installation of each release. The instructions are identical, so I assume the instructions will work on the other Devuan releases between these two.
These instructions appear lengthy because I included tests at each step to confirm the setup before going to the next step.
- The IP address of the x11vnc server. Example of finding the IP address:
sudo ifconfig
- A remote PC with a VNC client app. I tested using Devuan Jessie's "xvncviewer" app.
sudo apt-get install x11vnc
The X authority file is required for x11vnc to connect to the X server. If a user is logged in, that file is located at $HOME/.Xauthority. But if no one is logged in, then x11vnc will need the login manager (also known as the display manager)'s X authority file.
Devuan uses the SLiM login manager by default, so these instructions will find SLiM's X authority file. If you're using another login manager, you'll have to research that login manager.
more /etc/slim.conf
Look for the setting "authfile". The default is:
authfile /var/run/slim.auth
> Test x11vnc with this auth file from a console window
- Open a new terminal window for this test.
- Unset this environment variable so x11vnc doesn't use it to find an X authority file.
unset XAUTHORITY
- Start the x11vnc server WITHOUT specifying the X authority file.
sudo x11vnc -display :0
This should fail. The server exits immediately.
- Start the x11vnc server and specify the X authority file.
sudo x11vnc -auth /var/run/slim.auth -display :0
This should work. The server remains running. To stop the server: CTRL+C
- Close the test terminal window.
Choose a location to store the VNC password file. For these instructions, I chose /opt, because that directory is always empty on my PCs.
The max VNC password length is 8 characters. If you enter a longer password, the extra characters are ignored.
- Create a VNC password file.
sudo x11vnc -storepasswd /opt/yourx11vncpasswordfile
- View the password.
sudo x11vnc -showrfbauth /opt/yourx11vncpasswordfile
> Test the password.
- Open a new terminal window for this test.
sudo x11vnc -auth /var/run/slim.auth -display :0 -rfbauth /opt/yourx11vncpasswordfile
- On a remote PC, use a vnc client app and connect to this PC.
- Close the vnc client app. The VNC server automatically terminates.
- Close the test terminal window.
- Create an executable file in /etc/init.d. Then open it in a text editor.
cd /etc/init.d
sudo touch your11vnc
sudo chmod +x yourx11vnc
sudo <your text editor> yourx11vnc
- Copy this text to the script:
#!/bin/sh
### BEGIN INIT INFO
# Provides: yourx11vnc
# Required-Start: slim
# Required-Stop:
# Default-Start: 1 2 3 4 5
# Default-Stop: 0 6
# Short-Description: Your x11vnc server
# Description: This is your x11vnc server script.
### END INIT INFO
#Explanation of the args:
# -auth : Specifies the path to the X authority file required to connect to the X server. If no one is logged
# in, but the login screen is displayed, you can specify the X authority file of the login screen's
# display manager.
# -display : Tell x11vnc which display to try first. Otherwise, x11vnc will first try opening the display "", which
# fails. Then x11vnc will delay for 4 seconds, then try ":0", which finally works.
# -forever : Continue listening for more connections after the first client disconnects. By default, x11vnc exits
# when the client disconnects.
# -loop : Create an outer loop that restarts x11vnc whenever it terminates. Useful if the X server terminates
# and restarts, such as when logging out.
# -rfbauth : Use this password file created by "x11vnc --storepasswd". To run x11vnc without a password (NOT
# RECOMMENDED), remove this arg.
X11VNC_ARGS="-auth /var/run/slim.auth -display :0 -forever -loop -rfbauth /opt/yourx11vncpasswordfile"
X11VNC_BIN_PATH="/usr/bin/x11vnc"
case "$1" in
start)
#Any args after the "--" are passed unmodified to the program being started.
start-stop-daemon --start --oknodo --background --exec $X11VNC_BIN_PATH -- $X11VNC_ARGS
;;
stop)
start-stop-daemon --stop --oknodo --exec $X11VNC_BIN_PATH
;;
status)
start-stop-daemon --status --exec $X11VNC_BIN_PATH
STATUS_CODE=$?
#Print out a human readable message.
case $STATUS_CODE in
0) STATUS_MSG="$X11VNC_BIN_PATH is running."; ;;
1) STATUS_MSG="$X11VNC_BIN_PATH is not running, /var/run pid file exists."; ;;
2) STATUS_MSG="$X11VNC_BIN_PATH is not running, /var/lock lock file exists."; ;;
3) STATUS_MSG="$X11VNC_BIN_PATH is not running."; ;;
*) STATUS_MSG="Unknown status code: $STATUS_CODE"; ;;
esac
echo "$STATUS_MSG"
exit $STATUS_CODE
;;
*)
echo "Usage: $0 start|stop|status" >&2
;;
esac
* Optional adjustments to the script
- If you're using another display manager besides "slim":
- Change the "-auth" arg to match the display manager's X authority file.
- Change the "Required-Start" line to specify the name of the service that starts the display manager.
- If a VNC password is not required, remove the "-rfbauth /opt/yourx11vncpasswordfile" arg.
> Test the script manually
- To test the script, manually start the service.
sudo service yourx11vnc start
- On a remote PC, use a vnc client app and connect to this PC. This should work.
- Manually stop the service.
sudo service yourx11vnc stop
- Create the startup/shutdown links:
sudo update-rc.d yourx11vnc defaults
> Test the script on bootup
- Reboot the PC. If the PC has auto login enabled, log out to return to the login screen, so that you can confirm that x11vnc works without requiring anyone to be logged in.
- On a remote PC, use a vnc client app and connect to this PC. The remote PC should connect successfully and see the login screen.
- Manually stop the service.
sudo service yourx11vnc stop
- Edit the script:
sudo <your text editor> /etc/init.d/yourx11vnc
- Remove the -background option so the server's output is shown in the current console.
- Remove the -loop, so the server doesn't get stuck in an infinite loop if something's wrong.
- Manually start the service in a console window. The output will now be shown in the current console window, so you can troubleshoot the problem.
sudo service yourx11vnc start
To stop the server: CTRL+C
* Cleanup after troubleshooting
- Restore the -background and the -loop options.
- Manually restart the service.
sudo service yourx11vnc start
- Manually stop the service. Then disable the startup/shutdown links.
sudo service yourx11vnc stop
sudo update-rc.d yourx11vnc remove
- You can now move the script "yourx11vnc" from /etc/init.d to another directory, or delete it if you're SURE you don't need it.
Offline