Sample Header Ad - 728x90

How do I get x11vnc to turn on during Boot, without logging in, so I can access over SSH Tunnel?

5 votes
1 answer
4440 views
I am using Ubuntu 19.04. I want my VNC server on my Ubuntu computer to turn on during boot; I don't have a monitor plugged into it. I want to be able to run the full Ubuntu desktop remotely. I have managed to get my SSH server to work, and I can also get my x11vnc server to display on my Mac VNC client. However, this only works if I manually log in to Ubuntu and run the command
x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/USERNAME/.vnc/passwd -rfbport 5900 -share
I am able to create an SSH tunnel on my Mac and connect to it using a localhost:5900 connection. Next, I tried to make x11vnc turn on during boot, so I did the following. 1. sudo nano /lib/systemd/system/x11vnc.service 2. I saved the following text (123 is my gdm UID number)
[Unit]
    Description=Start x11vnc at startup.
    After=multi-user.target
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/x11vnc -loop -forever -bg -rfbport 5900 -xkb -noxrecord -noxfixes -noxdamage -shared -norc -auth /run/user/123/gdm/Xauthority -rfbauth /etc/x11vnc.pass
    
    [Install] 
    WantedBy=multi-user.target
3. I ran the following commands
sudo systemctl enable x11vnc.service
    sudo systemctl daemon-reload
    sudo systemctl start x11vnc.service
4. I rebooted but didn't log in to my Ubuntu computer. 5. I connected to SSH and created a tunnel successfully on my Mac. 6. I tried to connect to the VNC server, but that failed. 7. I then logged into my Ubuntu computer manually. 8. I tried to connect to the VNC server, managed to connect, but it was a black screen. So what I can tell is that the service only started when I log in to the Ubuntu session manually. Is there a way to do what I am trying to achieve? I am willing to use another server as well; I am only using x11vnc so that I wouldn't have to install a new desktop.
Asked by anarchy (155 rep)
Oct 9, 2019, 11:35 AM
Last activity: Oct 10, 2021, 06:50 AM