windows 远程连接Ubuntu18桌面

参考 Ubuntu18.04~Ubuntu22.04安装并配置VNC_ubuntu安装vnc-CSDN博客

1.Ubtuntu 上安装 x11vnc

sudo apt-get install x11vnc -y

设置密码

sudo x11vnc -storepasswd /etc/x11vnc.pass 

如果忘记密码,可以重新执行上述步骤重置密码

sudo systemctl restart x11vnc


安装完x11vnc之后需要给它配置个service,让它可以自动重启。创建service文件。

sudo vim /etc/systemd/system/x11vnc.service

将下面的内容写入上面创建的service文件,并保存。注意这个地方默认都是Ubuntu系统自带的组件,如果你的桌面不是gdm,下面的命令就可能不生效,所以维持操作系统原样就行。

[Unit]
Description=Start x11vnc at startup.
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth /run/user/1000/gdm/Xauthority -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared
[Install]
WantedBy=multi-user.target

配置好service之后还需要手动启动下,或者重启操作系统,这里我们选择手动启动。

sudo systemctl start x11vnc

启动之后去看下状态,如果没有报错就是成功了,可以使用软件测试了。查看状态不需要sudo权限,普通权限就行了。

systemctl status x11vnc

2.windows 上安装 VNC Viewer


输入远程ip,name随便写

---------------------------------

用一段时间,突然连不上了 报错: 

XOpenDisplay(":0") failed.

*** XOpenDisplay failed. No -display or DISPLAY.

systemctl status x11vnc

sudo startx  //启动一个display:

ctrl+z  //放在后台运行  

ps -aux|grep vnc

mobaXterm 登陆后显示

/usr/bin/xauth:  /home/nvidia/.Xauthority not writable, changes will be ignored
MoTTY X11 proxy: Unsupported authorisation protocol
MoTTY X11 proxy: Unsupported authorisation protocol
XCB failed to connect to the X server due to error:1.

参考:mobaXterm 無法打開服務器qt界面_motty x11 proxy: unsupported authorisation protoco-CSDN博客

猜你喜欢

转载自blog.csdn.net/qq_32636415/article/details/134663319