0

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?

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 logged into the system. But if no user has logged in first, I see this error in the log file:

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 ---
  • So... Try using the option it suggests? – muru Oct 17 '18 at 14:10
  • you mean -auth guess? i think this works when a user has already logged in. I need more robust suggestions. – eddys Oct 17 '18 at 14:18
0

Try adding the -create option to x11vnc. The command over ssh I use is:

ssh -t -L 5900:localhost:5900 192.168.1.131 "sudo x11vnc -localhost -create -auth guess  -display :0"

so I don't even need to have a service x11vnc running.


The ssh command maps the remote 5900 to the local port 5900, so the x11 server and viewer both think they are running locally on port 5900. A viewer command I use when invoking the above ssh command, explicitly uses localhost:5900 (the other options are just for performance).

xtightvncviewer -encodings RRE -bgr233 localhost::5900  

Assuming no password on the vnc server, the above will use the current username for the server, and ask for its password. If you have a different user on the server, include it in front of the IP with an @ sign. e.g. user@192...

  • I see localhost in the command. Would this not prevent logging in remotely? I need few days to try it because of some reasons. I will get back to you here with results. Seems very cool command. I seem to recall to use the "create" command but so much to search for I missed it. Anyways, it is hard to come up with the whole instruction. Thanks for your help:) – eddys Oct 18 '18 at 9:29
  • Hi @ubfan1, sorry but the command you gave me does not work. After executing the command it asks me for password but when i enter password it says try again!! – eddys Oct 24 '18 at 10:44
  • Hi @ubfan1, vnc should have a password obviously for security reasons. Do you have a tested instruction that works when vnc has a password? At least a suggestion. But mind you, an instruction that has not been tested rarely works when tried :D. Thanks for your all replies so far. – eddys Oct 25 '18 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.