1. 下载noNVC
git clone https://github.com/novnc/noVNC.git
2.创建安装连接
VNC的默认会话不是安全的,需要创建一个安全的VNC连接。创建完毕的证书 self.pem
需要放置到 noVNC/utils
目录下,当启动 noVNC 时,websockify将自动装载证书。
cd noVNC
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
一路回车下去
3.运行 noVNC,连接本机是5901的vnc服务
./utils/launch.sh --vnc localhost:5901
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PjpP6A5s-1669098082802)(img/1667372027736.png)]
http://uduntu-master:6080/vnc.html?host=uduntu-master&port=6080
4.打开链接,输入密码连接
http://192.168.122.218:6080/vnc.html
nano /opt/software/noVNC/utils/start_novnc.sh
复制下面到脚本
#!/bin/bash
nohup /opt/software/noVNC/utils/novnc_proxy --vnc localhost:5901 --listen 6080 &
chmod u+x /opt/software/noVNC/utils/start_novnc.sh
sudo nano /etc/systemd/system/novnc.service
4.1.复制下面到脚本
[Unit]
Description= noVNC Service(noVNC)
After=tigervnc.target
[Service]
# backend running
Type=forking
ExecStart=/opt/software/noVNC/utils/start_novnc.sh
ExecStop=/bin/kill -9 $(ps -e | grep 'receive' | awk '{print $1}')
Restart=on-failure
[Install]
WantedBy=multi-user.target
4.2.通知 systemd 我们创建了一个新的单元文件:
sudo systemctl daemon-reload
4.3.启用单元文件:
sudo systemctl enable novnc.service
4.4.执行以下命令启动 VNC 服务:
sudo systemctl start novnc.service
4.5.验证服务是否已成功启动:
sudo systemctl status novnc.service
4.6.重启服务器
sudo reboot
证服务是否已成功启动:**
sudo systemctl status novnc.service
4.6.重启服务器
sudo reboot