如何在ubuntu 24.04上安装配置x11vnc以便远程访问

在ubuntu 24.04上安装x11vnc的方法(经过验证04/25/2024)

sudo apt update

sudo apt install x11vnc

x11vnc -storepasswd

下面的命令确认authentication文件的位置(示例中的uid 1000)

systemctl status display-manager.service

Apr 25 22:54:30 hwnga-VMware20-1 gdm-password][4052]: pam_unix(gdm-password:session): session opened for user hwnga(uid=1000) by hwnga(uid=0)

ubuntu24.04默认使用waylan,但是x11vnc对于wayland不太友好,需要切换到xorg。logout,登录时只点击用户名,不输入密码,在屏幕右下角有个小的齿轮图标,点击,然后选择"ubuntu on xorg",再输入密码,登录。

下面的命令输出x11,证明从wayland成功切换到了xorg:

hwnga@hwnga-VMware20-1:~ echo XDG_SESSION_TYPE

x11

试着在用户hwnga下运行以下命令:

/usr/bin/x11vnc -auth /var/run/gdm3/auth-for-hwnga-*/database -forever -loop -noxdamage -repeat -rfbauth /home/hwnga/.vnc/passwd -rfbport 5900 -shared

如果没有错误,则可以在另外机器上运行vncviewer,确认可以连接成功。

再创建x11vnc systemd service,如下:

Unit

Description=Start x11vnc at startup.

After=gdm.service

Service

Type=simple

User=hwnga

Group=hwnga

ExecStart=/usr/bin/x11vnc -auth /var/run/gdm3/auth-for-hwnga-*/database -forever -loop -noxdamage -repeat -rfbauth /home/hwnga/.vnc/passwd -rfbport 5900 -shared

Install

WantedBy=multi-user.target

运行下面的命令,启动x11vnc service

hwnga@hwnga-VMware20-1:~$ sudo systemctl daemon-reload

hwnga@hwnga-VMware20-1:~$ sudo systemctl enable x11vnc-hwnga.service

hwnga@hwnga-VMware20-1:~$ sudo systemctl start x11vnc-hwnga.service

hwnga@hwnga-VMware20-1:~$ sudo systemctl status x11vnc-hwnga.service

● x11vnc-hwnga.service - Start x11vnc at startup.

Loaded: loaded (/etc/systemd/system/x11vnc-hwnga.service; disabled; preset>

Active: active (running) since Thu 2024-04-25 23:20:19 CDT; 6s ago

Main PID: 9502 (x11vnc)

Tasks: 2 (limit: 29004)

Memory: 30.1M (peak: 55.4M)

CPU: 70ms

CGroup: /system.slice/x11vnc-hwnga.service

├─9502 /usr/bin/x11vnc -auth "/var/run/gdm3/auth-for-hwnga-*/datab>

└─9503 /usr/bin/x11vnc -auth "/var/run/gdm3/auth-for-hwnga-*/datab>

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: 25/04/2024 23:20:23

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: The VNC desktop is: hwnga-V>

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: PORT=5900

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: ********************************>

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: Have you tried the x11vnc '-ncac>

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: The scheme stores pixel data off>

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: retrieval. It should work with >

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: x11vnc -ncache 10 ...

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: One can also add -ncache_cr for >

Apr 25 23:20:23 hwnga-VMware20-1 x11vnc[9503]: More info: http://www.karlrunge.>

hwnga@hwnga-VMware20-1:~$

下面是安全访问 (如何你不在外网访问,不需要此步骤):

先在ubuntu上安装openssh-server

sudo apt install openssh-server

sudo ufw allow ssh

sudo ufw allow 5900

sudo ufw enable

在window 上,安装mobaxterm, 开启tunelling。ssh server 是你的ubuntu的地址,端口22,用户名是ubuntu用户名。forward端口是你本地的一个未用的地址,比如6660。

在vnc reviewer上,使用localhost:6660来连接

相关推荐
__如风__1 小时前
内网环境下ubuntu 20.04搭建深度学习环境总结
linux·服务器·ubuntu
HetFrame13 小时前
John the Ripper jumbo + HashCat 破解压缩密码 ubuntu amd GPU
linux·ubuntu·amd·密码破解·john·压缩密码·hashcat
saynaihe15 小时前
关于Ubuntu的 update造成的内核升级
linux·运维·服务器·ubuntu·devops
小MarkK21 小时前
[Ubuntu][mount]ubuntu电脑挂载新硬盘
linux·ubuntu·电脑·mount·硬盘挂载
SabreWulf20202 天前
Ubuntu 20.04手动安装.NET 8 SDK
linux·ubuntu·avalonia·.net8
不是吧这都有重名2 天前
为什么ubuntu大文件拷贝会先快后慢?
linux·运维·ubuntu
DONG9992 天前
ubuntu 22 安装轻量级桌面Xfce并使用xrdp远程桌面连接
linux·运维·ubuntu
让子弹飞023 天前
36.2Linux单总线驱动DS18B20实验(详细讲解代码)_csdn
linux·ubuntu·驱动的分离和分层
朱自清的诗.3 天前
使用虚拟机Ubuntu搭建mosquito服务器 使esp32、上位机通信
ubuntu·esp32·mosquito
虎头金猫3 天前
如何在Linux上使用Docker在本地部署开源PDF工具Stirling PDF:StirlingPDF+cpolar让专业操作像在线文档一样简单
linux·运维·ubuntu·docker·pdf·开源·centos