让 x11vnc 在 Ubuntu 16.04 服务器中自动启动,无需有人先在服务器上进行物理登录

让 x11vnc 在 Ubuntu 16.04 服务器中自动启动,无需有人先在服务器上进行物理登录

我想要做的是自动启动 x11vnc 作为服务。然后假设当服务器因某种原因重新启动时,我将远程登录到远程 ubuntu 16.04 服务器,没有任何人都可以首先通过物理方式登录计算机。有什么线索可以做到这一点吗?

页面位于https://help.ubuntu.com/community/VNC/Servers#x11vnc说 x11vnc 可以在您的计算机仍显示登录屏幕时启动。我想这正是我的要求。

当我运行“x11vnc -findauth”时,我得到结果 XAUTHORITY=/run/user/1000/gdm/Xauthority。

仅供参考:我将此内容作为系统服务

[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

当任何用户首次登录系统时,它都可以正常工作。但如果没有用户首次登录,我会在日志文件中看到此错误:

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 ---

答案1

尝试将 -create 选项添加到 x11vnc。我通过 ssh 使用的命令是:

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

所以我甚至不需要运行服务 x11vnc。


ssh 命令将远程 5900 映射到本地端口 5900,因此 x11 服务器和查看器都认为它们在端口 5900 上本地运行。我在调用上述 ssh 命令时使用的查看器命令明确使用 localhost:5900(其他选项只是为了提高性能)。

xtightvncviewer -encodings RRE -bgr233 localhost::5900  

假设 vnc 服务器上没有密码,上述命令将使用服务器的当前用户名并要求输入其密码。如果服务器上有其他用户,请在 IP 前面加上 @ 符号。例如 user@192...

相关内容