RealVNC远程连接Ubuntu20.04(无显示器,开机后可连接)

场景

远程连接工控机时,无法使用VNC连接。需要以下配置菜可以在无屏幕情况下远程直接连接工控机,主要包括:

  • 使用Ubuntu内置的vino VNC提供远程桌面访问。
  • 配置自动登录
  • 配置虚拟桌面

环境

Ubuntu20.04

配置

1、安装Ubuntu内置的桌面共享VNC服务vino。

sudo apt install vino

在“设置->共享->屏幕共享”界面中为一个网络配置开启屏幕共享,设置密码。(提前需要有一块屏幕),可以通过其他方式配置

2、开启自动登录(跳过开机启动输入密码,有安全问题)

sudo vi /etc/gdm3/custom.conf
  • 输入以下内容:
[daemon]
AutomaticLoginEnable=true
  • 如果没有gdm需要安装gdm
sudo apt-get install gdm3

3、开启虚拟界面dummy monitor(在不接显示器情况下,Ubuntu不会启动桌面GUI)

sudo apt install xserver-xorg-video-dummy
  • 编辑文件(第一次编辑为空文件)
sudo vi /usr/share/X11/xorg.conf.d/xorg.conf
  • 编辑虚拟界面配置(配置为1024x768的分辨率)配置后重启即可
Section "Monitor"
  Identifier "Monitor0"
  HorizSync 28.0-80.0
  VertRefresh 48.0-75.0
  # https://arachnoid.com/modelines/
  # 1024x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 64.11 MHz
  Modeline "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795 -HSync +Vsync
EndSection
Section "Device"
  Identifier "Card0"
  Driver "dummy"
  VideoRam 256000
EndSection
Section "Screen"
  DefaultDepth 24
  Identifier "Screen0"
  Device "Card0"
  Monitor "Monitor0"
  SubSection "Display"
    Depth 24
    Modes "1024x768_60.00"
  EndSubSection
EndSection

注:

分辨率修改为1920x1080_60.00,重启后即使接入显示器也不会输出信号到显示器上。只可以VNC-Viewer远程登录。

Section "Monitor"
  Identifier "Monitor0"
  HorizSync 28.0-80.0
  VertRefresh 48.0-75.0
  # https://arachnoid.com/modelines/
  # 1024x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 64.11 MHz
  Modeline "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795 -HSync +Vsync
  Modeline "1920x1080_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync
EndSection
Section "Device"
  Identifier "Card0"
  Driver "dummy"
  VideoRam 256000
EndSection
Section "Screen"
  DefaultDepth 24
  Identifier "Screen0"
  Device "Card0"
  Monitor "Monitor0"
  SubSection "Display"
    Depth 24
    Modes "1920x1080_60.00"
  EndSubSection
EndSection

恢复:(删除配置文件)

sudo rm /usr/share/X11/xorg.conf.d/xorg.conf

立刻重启指令:

sudo shutdown -r now
posted @ 2024-07-04 10:56  Yimiu  阅读(17)  评论(0编辑  收藏  举报