1

I want to set up a headless server and connect to it from a laptop (Windows). It is running Kubuntu 15.04 and I installed X11vnc by this description:

VNC/Servers - Have x11vnc start automatically via systemd in any environment (Vivid+)

After a reboot the service is enabled and active (I think?), but I can not connect from the laptop using UltraVNC.

Only when I run

x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/USERNAME/.vnc/passwd -rfbport 5900 -shared

in a terminal I can connect to the server with UltraVNC.

I don´t want to issue this command everytime I want to the server. I want to be able to connect to server after a reboot without doing anything at the server.

Any ideas what goes wrong?

Hans
  • 11
  • 1
  • 1
  • 3

2 Answers2

0

Adding to what MikeyE posted. I followed effectively the same steps above but it would still not function. It needs two additions.

  1. x11vnc will NOT work if it is run as root. This will occur via systemctl if you do not set a user/group. Under the [Service] field add the following:

    User=<USERNAME>
    Group=<USERNAME>
    

    Doing this and restarting a x11vnc will generate a new error (which is fixed via what I describe in #2.

  2. A new error is displayed after doing the above. You now need a -display (or setting it via EXPORT). To see if this is your problem EXPORT DISPLAY=:0 prior to starting the service as MikeyE describes. After typing the command 'EXPORT DISPLAY=:0' then sudo systemctl restart x11vnc. It now worked for me.

    You will need a permanent way to set DISPLAY as the EXPORT method described above is lost on reboot. The above modifications to MikeyE's post allowed me to login to my Ubuntu installs.

user.dz
  • 48,105
  • Welcome to Ask Ubuntu. Answers move around based on whether one uses Active/Oldest/Votes is the sort orders in this question answer site. So, what you think is "above" may be "below" for me. Other answers may be deleted for various reasons. Therefore it is advised that you list all the steps in your answer to make it complete. – user68186 May 25 '21 at 19:36
0

Sounds like you didn't configure x11vnc as a system service, so that it's automatically started when the system boots. I just did the same thing you're trying to do, and it works. Execute the following and it should resolve your problem.

Step 1: Set a password specific to your username that you'll use to login to x11vnc from a remote system.

x11vnc -storepasswd

Enter a password and store the file to: /home/USERNAME/.vnc/passwd Note: make sure to replace USERNAME with your actual username.

Step 2: Configure the 'x11vnc.service' file so that vnc will be automatically started when the system boots up. You can use any text editor, but you'll need sudo access to edit the file. I'm using nano in the example here.

sudo nano /lib/systemd/system/x11vnc.service

Copy and paste the following lines into nano.

[Unit]
Description=Start x11vnc at startup.
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/USERNAME/.vnc/passwd -rfbport 5900 -shared

[Install]
WantedBy=multi-user.target

Exit and save the file by pressing 'Ctrl-X', then type 'Y' and press 'Enter'. Again, make sure you replace USERNAME with your actual username.

Step 3: Reload the services so your computer knows about the x11vnc service that you just configured in step 2 above. And enable the x11vnc service.

sudo systemctl daemon-reload
sudo systemctl enable x11vnc.service

Step 4: Start the x11vnc service.

sudo systemctl start x11vnc

Step 5: Celebrate! :-)

Conclusion

Following these steps should startup x11vnc and configure your system so that systemd, the system and service manager, will start x11vnc automatically every time the computer boots up.

References: I derived this answer from Ubuntu's documentation on VNC/Servers. Specifically, I referenced the sections titled "x11vnc" and "Have x11vnc start automatically via systemd in any environment (Vivid+)" .The second section I reference pertains to Ubuntu Vivid Vervet 15.04. If you're running a different version of a Debian linux distro, you'll need to reference the correct section from Ubuntu's VNC/Server page.

MikeyE
  • 105