Ubuntu18.04开启VNC实现windows远程访问图形界面

1.windows端安装VNC Viewer

官网下载客户端:

Download VNC Viewer | VNC® Connect

2.Ubuntu 18.04配置

若安装的ubuntu系统不带图形界面,那么首先安装图形界面:

sudo apt-get install ubuntu-desktop
sudo reboot now

安装panel、daemon等:

sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

安装vnc:

sudo apt-get install x11vnc

安装lightdm,弹出设置中选择lightdm确认:

sudo apt-get install lightdm

创建vnc配置目录,其中“********”为VNC连接密码:

cd ~
mkdir .vnc
cd .vnc
sudo x11vnc -storepasswd ******** passwd

生成VNC配置文件:

touch x11vnc.service

打开文件,填充以下内容:

nano 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 /home/**/.vnc/passwd -rfbport 5900 -shared 
 
[Install] 
WantedBy=multi-user.target

"ExexStart"中“**”为用户名

将配置文件移至/lib/systemd/sydtem/目录,并修改权限:

sudo mv x11vnc.service /lib/systemd/system/.
sudo chown root:root /lib/systemd/system/x11vnc.service

加载服务配置文件,查看服务开启情况:

sudo systemctl daemon-reload
sudo systemctl list-unit-files | grep x11vnc

设置开机启动VNC:

sudo systemctl enable x11vnc.service
sudo reboot now

启动后,查看监听端口:

sudo ss -tunlp

3.远程VNC连接

windows下打开客户端,File->New connection,输入ubuntu设备IP,后缀5900端口,密码为前面配置的VNC连接密码:

连接成功:

4.无显示器情况下连接

安装虚拟显示器依赖的驱动:

sudo apt-get install  xserver-xorg-core-hwe-18.04
sudo apt-get install  xserver-xorg-video-dummy-hwe-18.04  --fix-missing

新增配置文件(/etc/X11/xorg.conf 或者/usr/share/X11/xorg.conf.d/xorg.conf ),填充内容:

sudo nano /etc/X11/xorg.conf 
Section "Device"
    Identifier  "Configured Video Device"
    Driver      "dummy"
EndSection

Section "Monitor"
    Identifier  "Configured Monitor"
    HorizSync 31.5-48.5
    VertRefresh 50-70
EndSection

Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    Device      "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
        Depth 24
        Modes "1920x1080"
    EndSubSection
EndSection

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>