ubuntu web端远程桌面控制

本文详细介绍了在Ubuntu系统中安装x11vnc并配合novnc进行配置,包括安装步骤、创建systemd服务、启动novnc以及访问方法。特别提到了兼容性问题和解决方案。
[Unit]

Description=Start x11vnc at startup.

After=multi-user.target

[Service]

Type=simple

ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared

[Install]

WantedBy=multi-user.target

x11vnc注意不支持wayland,也不支持gdm3,需要切换到x11和lightdm,可以自行网上找资料

  • 本文主要介绍novnc的安装及配置

1.安装novnc

sudo snap install novnc

2.配置novnc

创建文件 /lib/systemd/system/novnc.service

[Unit]

Description=Start novnc at startup.

After=multi-user.target

[Service]

Type=simple


ExecStart=/snap/bin/novnc --listen 6081 --vnc :5900

[Install]

WantedBy=multi-user.target

3.启动novnc

systemctl enable novnc

systemctl start novnc

4访问

重启电脑后,用其他电脑浏览器访问: ip:6081/vnc.html

点击页面中间的连接按钮,输入密码后就可以远程控制了

注意:我试过有些情况不能连接成功的,一般都是页面能出现,但是点击连接按钮后提示连接失败;

         可以尝试换浏览器,我就试过用firefox出现上述情况,使用chrome正常.

同时,也可简单体验一下项目:https://github.com/Frederic-Boulanger-UPS/docker-ubuntu_22-04-novnc

### Ubuntu Web Remote Desktop Cross-Origin Solution For addressing cross-origin issues in an Ubuntu web-based remote desktop setup, ensuring secure and functional access involves several considerations. The configuration of the server to handle CORS (Cross-Origin Resource Sharing) is critical. When setting up a web-based remote desktop service on Ubuntu, modifying the Apache or Nginx configurations can help manage these requests effectively[^1]. To implement this solution, one should adjust the HTTP headers sent by the webserver that serves as the gateway for accessing the remote desktop environment. For instance, adding specific directives within the virtual host settings allows browsers to recognize permissions granted across different origins. #### Adjusting Nginx Configuration ```nginx location / { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; if ($request_method = 'OPTIONS') { return 204; } } ``` This snippet ensures that any origin attempting to connect receives permission through appropriate headers, thus mitigating common cross-origin problems encountered during remote desktop connections via a browser interface. Moreover, securing such setups requires careful consideration beyond just enabling CORS policies. Implementing authentication mechanisms like OAuth tokens or JWTs adds another layer of security when interfacing remotely with services hosted on an Ubuntu system. --related questions-- 1. How does implementing OAuth improve security in web-based applications? 2. What are alternative methods to configure CORS besides adjusting Nginx settings? 3. Can you provide examples of using JWT for authenticating users connecting to a remote desktop over the web?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值