ubuntu如何搭建vnc(Ubuntu20.04 VNC 安装与设置实现)
类别:服务器 浏览量:536
时间:2022-03-31 12:52:03 ubuntu如何搭建vnc
Ubuntu20.04 VNC 安装与设置实现VNC是一个远程桌面协议。按照本文的说明进行操作可以实现用VNC对Ubuntu 20.04进行远程控制。一般的VNC安装方式在主机没有插显示器的时候是无法使用的。下面的操作可以在主机有显示器和没有显示器时都能够正常工作。
首先安装x11vnc
sudo apt-get install x11vnc -y
设置vnc密码
sudo x11vnc -storepasswd /etc/x11vnc.pass
创建x11vnc自启动服务
创建 /etc/systemd/system/x11vnc.service,并写入以下内容
[Unit] Description=Start x11vnc at startup. After=multi-user.target [Service] Type=simple ExecStart=/usr/bin/x11vnc -auth /run/user/1000/gdm/Xauthority -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared [Install] WantedBy=multi-user.target
启动x11vnc服务
sudo systemctl enable x11vnc sudo service x11vnc start
此时如果远程的主机上接了显示器,那么就可以在局域网通过VNC进行访问了。
为了能够保证远程主机无论是否有显示器,我们都能通过VNC进行远程访问,我们还要做下面的修改
创建默认的xorg.conf文件
sudo Xorg :1 -configure
此时程序会生成 /root/xorg.conf.new文件
我的默认文件内容如下
Section "ServerLayout" Identifier "X.org Configured" Screen 0 "Screen0" 0 0 InputDevice "Mouse0" "CorePointer" InputDevice "Keyboard0" "CoreKeyboard" EndSection Section "Files" ModulePath "/usr/lib/xorg/modules" FontPath "/usr/share/fonts/X11/misc" FontPath "/usr/share/fonts/X11/cyrillic" FontPath "/usr/share/fonts/X11/100dpi/:unscaled" FontPath "/usr/share/fonts/X11/75dpi/:unscaled" FontPath "/usr/share/fonts/X11/Type1" FontPath "/usr/share/fonts/X11/100dpi" FontPath "/usr/share/fonts/X11/75dpi" FontPath "built-ins" EndSection Section "Module" Load "glx" EndSection Section "InputDevice" Identifier "Keyboard0" Driver "kbd" EndSection Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "auto" Option "Device" "/dev/input/mice" Option "ZAxisMapping" "4 5 6 7" EndSection Section "Monitor" Identifier "Monitor0" VendorName "Monitor Vendor" ModelName "Monitor Model" EndSection Section "Device" ### Available Driver options are:- ### Values: <i>: integer, <f>: float, <bool>: "True"/"False", ### <string>: "String", <freq>: "<f> Hz/kHz/MHz", ### <percent>: "<f>%" ### [arg]: arg optional #Option "Accel" # [<bool>] #Option "AccelMethod" # <str> #Option "Backlight" # <str> #Option "CustomEDID" # <str> #Option "DRI" # <str> #Option "Present" # [<bool>] #Option "ColorKey" # <i> #Option "VideoKey" # <i> #Option "Tiling" # [<bool>] #Option "LinearFramebuffer" # [<bool>] #Option "HWRotation" # [<bool>] #Option "VSync" # [<bool>] #Option "PageFlip" # [<bool>] #Option "SwapbuffersWait" # [<bool>] #Option "TripleBuffer" # [<bool>] #Option "XvPreferOverlay" # [<bool>] #Option "HotPlug" # [<bool>] #Option "ReprobeOutputs" # [<bool>] #Option "XvMC" # [<bool>] #Option "ZaphodHeads" # <str> #Option "VirtualHeads" # <i> #Option "TearFree" # [<bool>] #Option "PerCrtcPixmaps" # [<bool>] #Option "FallbackDebug" # [<bool>] #Option "DebugFlushBatches" # [<bool>] #Option "DebugFlushCaches" # [<bool>] #Option "DebugWait" # [<bool>] #Option "BufferCache" # [<bool>] Identifier "Card0" Driver "intel" BusID "PCI:0:2:0" EndSection Section "Screen" Identifier "Screen0" Device "Card0" Monitor "Monitor0" SubSection "Display" Viewport 0 0 Depth 1 EndSubSection SubSection "Display" Viewport 0 0 Depth 4 EndSubSection SubSection "Display" Viewport 0 0 Depth 8 EndSubSection SubSection "Display" Viewport 0 0 Depth 15 EndSubSection SubSection "Display" Viewport 0 0 Depth 16 EndSubSection SubSection "Display" Viewport 0 0 Depth 24 EndSubSection EndSection
将此文件复制至 /usr/share/X11/xorg.conf.d/xorg.conf
这个文件保证在主机上插有显示器的时候,系统界面能在显示器上正常显示。下面我们再给系统添加一个虚拟显示器,当主机没有显示器的时候系统就使用这个虚拟显示器。
安装虚拟显卡驱动
sudo apt install xserver-xorg-video-dummy
在这个文件的最后添加下面的内容
Section "Monitor" Identifier "Monitor1" HorizSync 1.0 - 2000.0 VertRefresh 1.0 - 200.0 # Add 16:9 modes, others are automatically detected. Modeline "1280x720" 74.48 1280 1336 1472 1664 720 721 724 746 Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 EndSection Section "Device" Identifier "Card1" Driver "dummy" VideoRam 256000 EndSection Section "Screen" DefaultDepth 24 Identifier "Screen1" Device "Card1" Monitor "Monitor1" SubSection "Display" Depth 24 Modes "1920x1080" EndSubSection EndSection
这样我们就创建了一个使用虚拟显卡的虚拟显示器。为了让虚拟的显示器和真实显示器都能工作,我们需要把最上面的ServerLayout 进行更改
Section "ServerLayout" Identifier "X.org Configured" Screen 0 "Screen0" 0 0 Screen 1 "Screen1" 0 0 EndSection
现在重新启动远程电脑,就可以在没有显示器的情况下远程了。
以上的方法还有一个问题。就是在用户没有登录的其情况下是没办法远程的。所以需要把用户设置成自动登录。
到此这篇关于Ubuntu20.04 VNC 安装与设置实现的文章就介绍到这了,更多相关Ubuntu20.04 VNC 安装与设置内容请搜索开心学习网以前的文章或继续浏览下面的相关文章希望大家以后多多支持开心学习网!
标签:Ubuntu20.04 VNC
您可能感兴趣
- gitlablinux安装配置(Ubuntu20.04安装配置GitLab的方法步骤)
- ubuntu20.04安装启动问题(安装ubuntu18.04报:failed to load ldlinux.c32的问题及解决步骤)
- ubuntu11.04安装ssh失败(Ubuntu20.04桌面安装及root权限开通和ssh安装详解)
- ubuntu16.04开机默认root(新版ubuntu20.04 使用root用户登录系统的详细教程)
- ros必须在ubuntu安装吗(详解ubuntu20.04下CLion2020.1.3安装配置ROS过程说明)
- ubuntu20.04开启ssh(详解Ubuntu20.04用Xshell通过SSH连接报错的服务问题)
- ubuntu如何搭建vnc(Ubuntu20.04 VNC 安装与设置实现)
- ubuntu18.04更换软件源(ubuntu20.04 LTS系统默认源sources.list文件的修改)
- 《祝卿好》台词又土又甜,就喜欢这么直接的恋爱(祝卿好台词又土又甜)
- 大女主 汤唯垂青电视圈,搭档朱亚文出演《大明皇妃孙若微传》(汤唯垂青电视圈)
- 红色代表什么(红色代表什么情感和含义)
- 高中数学题(高中数学题型总结及解题方法)
- 冰岛旅游攻略(冰岛旅游攻略及花费)
- 为什么现在年轻人越来越喜欢买衣服(为什么现在年轻人越来越喜欢买衣服穿)
热门推荐
- 排序算法口诀php(PHP快速排序算法实现的原理及代码详解)
- 自建FTP服务器并远程外网访问,花生棒自带端口映射3步搞定(自建FTP服务器并远程外网访问,花生棒自带端口映射3步搞定)
- 阿里云mysql如何接入(阿里云服务器安装Mysql数据库的详细教程)
- mysql server安装图解教程(mysql容器之间的replication配置实例详解)
- SQL Server Management Studio(SSMS)复制数据库的方法(SQL Server Management StudioSSMS复制数据库的方法)
- win10下安装mysql8.0.23 及 “服务没有响应控制功能”问题解决办法(win10下安装mysql8.0.23 及 “服务没有响应控制功能”问题解决办法)
- javascript如何跨域
- 宝塔nginx装哪个版本(宝塔面板nginx关闭状态,启动不了解决办法)
- sqlserver中根据日期时间获取秒数(sql server编写通用脚本实现获取一年前日期的方法)
- 前端webpack方面的优化(webpack的移动端适配方案小结)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8