我想启用远程 VNC 登录到 debian 上的 lightdm 会话,以便我可以远程登录。我取消注释了 in [VNCServer]
,/etc/lightdm/lightdm.conf
然后重新启动lightdm.service
[VNCServer]
enabled=true
command=/usr/bin/Xvnc
port=5900
width=1024
height=768
depth=8
root@deb2:~# systemctl restart lightdm.service
端口 5900 现已开放,lightdm 正在监听
root@deb2:~# ss -ltnpu
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
......
tcp LISTEN 0 10 0.0.0.0:5900 0.0.0.0:* users:(("lightdm",pid=1622,fd=11))
我创建一个本地 SSH 隧道,然后使用以下命令进行远程连接vncviewer
:
admin@:~$ ssh -L 5900:localhost:5900 [email protected]
admin@:~$ vncviewer -Log *:stderr:100 127.0.0.1:5900
TigerVNC Viewer 64-bit v1.10.1
Built on: 2020-04-09 06:49
Copyright (C) 1999-2019 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Fri Apr 29 14:29:48 2022
DecodeManager: Detected 2 CPU core(s)
DecodeManager: Creating 2 decoder thread(s)
TcpSocket: Connecting to 192.168.1.241 [192.168.1.241] port 5900
CConn: Connected to host 192.168.1.241 port 5900
CConnection: reading protocol version
CConn: End of stream
如您所见,VNC 连接但随后立即退出。
在 lightdm 日志中/var/log/lightdm/lightdm.log
(粘贴在这里) 我看到连接已接收并且显示服务器已启动但随后它似乎立即关闭。
我还想实际连接到本地机器上实际运行的显示器(即显示器:0),而不是创建新的显示器这似乎就是这里发生的事情:
[+27.51s] DEBUG: Launching process 2119: /usr/bin/Xvnc :1 -auth /var/run/lightdm/root/:1 -nolisten tcp -inetd -geometry 1024x768 -depth 8
[+27.52s] DEBUG: XServer 1: Waiting for ready signal from X server :1
正如您所看到的,Xvnc 被调用时显示的是显示号 :1,而不是 :0,而这正是我想要的
/usr/bin/Xvnc :1 -auth /var/run/lightdm/root/:1 -nolisten tcp -inetd -geometry 1024x768 -depth 8
我真的很感激任何关于如何实现这个功能的想法,谢谢!
[+27.51s] DEBUG: Got VNC connection from 127.0.0.1:44548
[+27.51s] DEBUG: Seat vnc1: Loading properties from config section Seat:*
[+27.51s] DEBUG: Seat vnc1: Starting
[+27.51s] DEBUG: Seat vnc1: Creating greeter session
[+27.51s] DEBUG: Seat vnc1: Creating display server of type x
[+27.51s] DEBUG: XServer 1: Logging to /var/log/lightdm/x-1.log
[+27.51s] DEBUG: XServer 1: Writing X server authority to /var/run/lightdm/root/:1
[+27.51s] DEBUG: XServer 1: Launching X Server
[+27.51s] DEBUG: Launching process 2119: /usr/bin/Xvnc :1 -auth /var/run/lightdm/root/:1 -nolisten tcp -inetd -geometry 1024x768 -depth 8
[+27.52s] DEBUG: XServer 1: Waiting for ready signal from X server :1
[+27.52s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat2
[+27.55s] DEBUG: Process 2119 exited with return value 1
[+27.55s] DEBUG: XServer 1: X server stopped
[+27.55s] DEBUG: XServer 1: Removing X server authority /var/run/lightdm/root/:1
[+27.55s] DEBUG: Seat vnc1: Display server stopped
[+27.55s] DEBUG: Seat vnc1: Stopping session
[+27.55s] DEBUG: Seat vnc1: Session stopped
[+27.55s] DEBUG: Seat vnc1: Stopping display server, no sessions require it
[+27.55s] DEBUG: Seat vnc1: Stopping; greeter display server failed to start
[+27.55s] DEBUG: Seat vnc1: Stopping
[+27.55s] DEBUG: Seat vnc1: Stopped
root@deb2:~# update-alternatives --query Xvnc
Name: Xvnc
Link: /usr/bin/Xvnc
Slaves:
Xvnc.1.gz /usr/share/man/man1/Xvnc.1.gz
Status: auto
Best: /usr/bin/Xtigervnc
Value: /usr/bin/Xtigervnc
Alternative: /usr/bin/Xtigervnc
Priority: 80
Slaves:
Xvnc.1.gz /usr/share/man/man1/Xtigervnc.1.gz
root@deb2:~#
root@deb2:/var/log/lightdm# ls -lat /usr/bin/Xvnc lrwxrwxrwx 1 root root 22 Apr 26 11:04 /usr/bin/Xvnc -> /etc/alternatives/Xvnc
答案1
我认为问题与添加到 Xvnc 调用的默认 -depth 8 参数有关。最近版本已删除对 8 位深度的支持。请参阅:https://github.com/canonical/lightdm/pull/265/commits/02e3d25724a9df88631b4c7c5f0dab409db6a0a2。
我遇到了同样的问题,导致 X 服务器(与 Xvnc 捆绑在一起)出现致命错误。
答案2
不知道为什么这不起作用,但我已经使用 xinetd 实现了我想要的
在您的工作机器上,apt-get install xinetd tigervnc-standalone-server
编辑并/etc/lightdm/lightdm.conf
包含以下行:
[XDMCPServer]
enabled=true
port=177
listen-address=localhost
/etc/xinetd.d/Xvnc
使用以下内容创建:
service xvnc_1
{
type = UNLISTED
disable = no
protocol = tcp
socket_type = stream
bind = 127.0.0.1
port = 5900
wait = yes
user = root
server = /usr/bin/Xvnc
server_args = :1 -inetd -query localhost -geometry 1600x1200 -depth 24 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared -SecurityTypes None
}
要在所有接口上启用监听,请删除上面的几行:
listen-address=localhost
bind = 127.0.0.1
现在重新启动 xinetd 和 lightdm:systemctl restart xinetd lightdm
来源:https://users.dcs.aber.ac.uk/auj/en/office-remote-linux/
此外,要禁用任何身份验证消息,请参阅以下有关设置正确的 polkit 策略的文章:https://c-nergy.be/blog/?p=12073