这个VNC可真是搞了有一段时间了,从一开始有问题到后来远程连上本地就会断开断断续续碰到各种问题,直到那天看到一篇x11vnc的教程,终于搞成功了。。。
留作记录。
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
1 安装 X11VNC
sudo apt install x11vnc
2 配置访问密码
sudo x11vnc -storepasswd /etc/x11vnc.pass
3 创建systemctl服务
sudo vim /lib/systemd/system/x11vnc.service
[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
4 配置防火墙,配置和启动服务
sudo ufw allow 5900
#默认端口5900
sudo systemctl enable x11vnc.service
#开启x11vnc服务
sudo systemctl daemon-reload
sudo systemctl restart x11vnc.service #重启x11vnc服务
5 启动x11vnc server
sudo service x11vnc start
#设置分辨率为1920*1080
6 修改分辨率
如果机器上没有连接显示器的话,那么大概率重启以后只有一个800*600的小窗口,我们可以通过下面两种方式修改:
6.1 x11配置文件
sudo vim /etc/X11/xorg.conf
#创建配置文件
文件内容:(注意缩进)
Section "Device"
Identifier "Configured Video Device"
EndSection
Section "Monitor"
Identifier "Configured Monitor"
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
SubSection "Display"
Depth 24
Virtual 1920 1080
EndSubSection
EndSection
将内容中的1920 1080
修改为你需要的分辨率,配置完成后重启
6.2 使用xrandr命令
xrandr --fb 1280x1024
#1280x1024为分辨率