简体   繁体   中英

Have x11vnc automatically start in Ubuntu 16.04 server without someone first logging in at the server physically

What i would like to do is automatically start x11vnc as a service. Then lets say when the server restarts for some reason, i would remotely login to the remote ubuntu 16.04 server, WITHOUT anybody logging in physically to the computer at first. Any clues how this can be done? Thanks!.

The page at https://help.ubuntu.com/community/VNC/Servers#x11vnc says that x11vnc can be started while your computer is still showing a login screen. I think this is exactly my requirement.

When i run "x11vnc -findauth" i get the result XAUTHORITY=/run/user/1000/gdm/Xauthority.

FYI: i made it as a system service with this content

[Unit]

Description=Start x11vnc at startup.

After=multi-user.target

[Service]

Type=simple

ExecStart=/usr/bin/x11vnc -auth /run/user/1000/gdm/Xauthority -display :1 -forever -loop -noxdamage -repeat -rfbauth /home/mms2/.vnc/passwd -rfbport 5900 -shared

[Install]

WantedBy=multi-user.target

It works fine when any user has first loggin to the system. But if not user has logged in first, i see this error in the log file

Oct 16 19:45:19 ubuntu x11vnc[1486]: dtlogin: -auth

/var/dt/A:0-UgaaXa Oct 16 19:45:19 ubuntu x11vnc[1486]: Sometimes

the command "ps wwwwaux | grep auth" can reveal the file location. Oct

16 19:45:19 ubuntu x11vnc[1486]: Starting with x11vnc 0.9.9 you can

have it try to guess by using: Oct 16 19:45:19 ubuntu x11vnc[1486]:

-auth guess Oct 16 19:45:19 ubuntu x11vnc[1486]: (see also the x11vnc -findauth option.) Oct 16 19:45:19 ubuntu x11vnc[1486]: Only

root will have read permission for the file, and so x11vnc must be run

Oct 16 19:45:19 ubuntu x11vnc[1486]: as root (or copy it). The

random characters in the filenames will of course Oct 16 19:45:19

ubuntu x11vnc[1486]: change and the directory the cookie file

resides in is system dependent. Oct 16 19:45:19 ubuntu x11vnc[1486]:

See also: http://www.karlrunge.com/x11vnc/faq.html Oct 16 19:45:19

ubuntu x11vnc[1486]: --- x11vnc loop: sleeping 2000 ms ---

It's to do with how the different sessions are started and where you're trying to connect (I'm sure someone more technical can be more specific). Basically, you need two separate services, 1) for logging into system and starting the desktop and 2) using the desktop.

You need to create another similar service called "x11vnc-login" or whatever. However, change the "x11vnc-login" service listen on port 5900 and your "x11vnc" service listen on 5901. You will also need to change the auth info for each to match the relevant user, for me it's /run/user/1000/... for the 5901 and /run/user/121/... for the 5900.

Then when you want to connect, tunnel in and VNC to 5900. That will give you the login screen where you can enter your details and it will go black. Shut the connection and connect on 5901 and you're good to go!

After a lot of searching and frustration, I found this answer at the bottom of a comment section that is by far the the easiest workaround. I wish I could find the link again because that person deserves the credit, but it's slipped back away so you'll have to do with my second hand stuff.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM