How To Install and Configure VNC Server on Ubuntu 20.04

2023-05-16

From:

https://tecadmin.net/install-vnc-server-on-ubuntu-20-04/#:~:text=1%20How%20To%20Install%20and%20Configure%20VNC%20Server,%E2%80%93%20Create%20a%20Systemd%20Service%20File%20for%20VNC.

-- Only need Start from step2.


VNC stands for “Virtual Network Computing” is a sharing system or set of protocols for sharing desktops. There is much software available to access Linux-based desktop remotely including, TigerVNC, TightVNC, Vino, vnc4server, and more.

TigerVNC is a free, open-source, and high-performance VNC server used to control or access Linux-based desktop remotely. It is a client/server application that allows you to interact with graphical applications on remote machines.

  • Read: How to Install Remote Desktop (XRDP) on Ubuntu 20.04

In this tutorial, we will show you how to install and configure a VNC server on Ubuntu 20.04.

Step 1 – Install Desktop Environment

By default, Ubuntu Server does not include a Desktop Environment. TigerVNC server is designed to controls only desktop systems. So you will need to add a desktop environment to your server.

 

First, update and upgrade all installed packages with the following command:

apt update -y 
apt upgrade -y 

Once your system is updated, install the Tasksel utility to install a desktop environment:

ADVERTISEMENT

apt install tasksel -y 

After installing Tasksel, launch the Tasksel utility with the following command:

tasksel 

You should see the following interface:

Use the arrow key to scroll down the list and find Ubuntu desktop. Next, press the Space key to select it then press the Tab key to select OK then hit Enter to install the Ubuntu desktop.

Once all the packages are installed, you will need to set your system boots into the graphical target. You can set it with the following command:

systemctl set-default graphical.target 

Next, restart your system to apply the changes.

Step 2 – Install TigerVNC Server

By default, the TigerVNC package is available in the Ubuntu 20.04 default repository. You can install it by just running the following command:

apt install tigervnc-standalone-server -y 

(切换user的动作可以不做!)

After installing TigerVNC, create a new user and set a VNC password for that user.

First, create a new user named hitesh with the following command:

adduser hitesh 

Next, switch the user to hitesh and set a VNC password with the following command:

su - hitesh 
vncpasswd 

Provide your desired password as shown below:


Password:
Verify:
Would you like to enter a view-only password (y/n)? n
  

Next, start the VNC server using the following command:

(遇到过必须用sudo启动vncserver才能成功,具体原因等待继续看。另外,下面的vncserver是一个链接,链接到了tighervnc)

vncserver -localhost no 

Once the VNC server is started, you should get the following output:


New 'ubuntu2004:1 (hitesh)' desktop at :1 on machine ubuntu2004

Starting applications specified in /etc/X11/Xvnc-session
Log file is /home/hitesh/.vnc/ubuntu2004:1.log

Use xtigervncviewer -SecurityTypes VncAuth,TLSVnc -passwd /home/hitesh/.vnc/passwd ubuntu2004:1 to connect to the VNC server.
  

You can verify your running VNC server using the following command:

vncserver -list 

You should get the following output:


TigerVNC server sessions:

X DISPLAY #	RFB PORT #	PROCESS ID
:1		5901		1719
  

Step 3 – Install VNC Client

(我在windows上安装的client是vnc viewer, 登录配置是一样的,可能RealVNC更好吧)

In this section, we will install the RealVNC VNC client on the remote machine and connect it to the VNC server.

You can download the RealVNC client from the RealVNC download page.

Once the download is completed, install the downloaded package with the following command:

dpkg -i /home/vyom/Downloads/VNC-Viewer-6.20.529-Linux-x64.deb  

Next, launch the VNC client from the Gnome application menu. Then, Click on the File menu => New connection to create a new connection. You should see the following screen:

 

Provide the Name(linux用户名) and IP address along with VNC session ID :1 of your VNC server and click on the OK to save the connection. You should see your saved connection in the following screen:

Now, double click on your newly created connection. You will be asked to provide your VNC password:

 

Provide your VNC password and click on the OK. Once connected, you should see your Ubuntu desktop screen: (看来没有显示左侧的工具栏是正常的哈)

 

Step 4 – Configure VNC to Work with Your Desktop Environment

Before starting, stop the VNC instance using the vncserver command with a -kill option and the server session ID as an argument.

vncserver -kill :1 

You should get the following output:

Killing Xtigervnc process ID 1719… success!

Next, you will need to configure TigerVNC to work with Gnome(如果用的是ligthDM呢??). You can do it by creating new file xstartup inside .vnc directory:

su - hitesh 
nano ~/.vnc/xstartup

Add the following lines:

#!/bin/sh
exec /etc/vnc/xstartup
xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session gnome-session &

 

Save and close the file when you are finished. The above script will be executed automatically whenever you start or restart the TigerVNC server.

Next, give execute permissions to the ~/.vnc/xstartup file:

chmod u+x  ~/.vnc/xstartup 

Step 5 – Create a Systemd Service File for VNC

Next, you will need to create a systemd file for TigerVNC to manage the VNC service. You can create it with the following command:

nano /etc/systemd/system/vncserver@.service 

Add the following lines:

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
User=hitesh
PAMName=login
PIDFile=/home/%u/.vnc/%H%i.pid
ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :
ExecStart=/usr/bin/vncserver :%i -localhost no -geometry 1024x768
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

Save and close the file then reload the systemd daemon with the following command:

systemctl daemon-reload 

Next, enable the VNC service to start at system reboot with the following command:

systemctl enable vncserver@1.service 

Next, start the VNC service with the following command:

systemctl start vncserver@1.service 

Conclusion

Congratulations! you have successfully installed and set up the Tiger VNC server on Ubuntu 20.04. You can now connect your Ubuntu system from any desktop system and manage it with easy to use graphical interface.

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

How To Install and Configure VNC Server on Ubuntu 20.04 的相关文章

  • On make and cmake

    你或许听过好几种 Make 工具 xff0c 例如 GNU Make xff0c QT 的 qmake xff0c 微软的MS nmake xff0c BSD Make xff08 pmake xff09 xff0c Makepp xff0
  • img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation代码理解

    import argparse import os import sys import time import numpy as np from PIL import Image ImageOps from torchvision impo
  • Linux下安装opencv with-ffmpeg解决无法读取视频的问题

    Linux下安装opencv with ffmpeg解决无法读取视频的问题 参考文章 1 Linux下安装opencv with ffmpeg解决无法读取视频的问题 2 https www cnblogs com haiyang21 p 1
  • CentOS7.x安装VNC实录

    不知不觉 centos已经到7 6了 在服务器操作系统中 centos是用的比较多的 占很大的比例 由于7 x版本和6 x版本有区别 最近安装了7 6的VNC 特记之 VNC需要系统安装的有桌面 如果是生产环境服务器 安装时使用的最小化安装
  • VNC unable to connect via 127.0.0.1:1080

    VNC远程登录出现自己电脑拒绝的时候 请查看一下自己是否设了代理登录之类的操作 这里是WIN 10 登录远程一台WIN 10 服务器 跟服务器设置没有什么关系 主要由于本地配置导致的 解决方案 File里面选择属性 取消代理设置即可 折腾了
  • Centos 7 VNC配置及黑屏原因 (图文教程)

    Centos 7 VNC配置或安装的教程很多 鱼龙混杂 这里写一篇经过实践证明的真理配置方法 以正视听 Centos 7 安装VNC非常简单 要比Ubuntu简单多了 因为Ubuntu默认Unity桌面不支持VNC 1 关闭防火墙 syst
  • 用树莓派搭建远程实时画面传输

    目录 一 材料准备 二 环境搭建 1 树莓派实现局域网监控画面传输 1 树莓派安装系统 2 将摄像头与树莓派连接 3 配置树莓派开发环境 4 让摄像头开始进行画面录制 5 将监控画面服务设置为开机自启 2 内网渗透 1 服务器端frp配置
  • electron在window7上安装白屏问题

    问题描述 electron5 0 13以上的版本打包win7上需要 NET Framework 4 6 版本及以上版本才可以运行 但是有些win7由于是SP1的系统属于精简版window所以无法安装 NET Framework 4 6及其以
  • vnc远程管理kvm,在办公室连接kvm服务器

    文章目录 vnc远程管理kvm vnc远程管理kvm vnc概念图 首先试试服务器装了VNC没 rpm q tigervnc tigervnc server 没安装的话会直接出现 package tigervnc is not instal
  • 《银河麒麟高级服务器操作系统V10》使用

    一言而论 讲了麒麟服务器V10的基本使用 包括终端 VNC 文章目录 前言 基本架构 环境 硬件环境 软件环境 麒麟安装步骤 1 在宿主机上安装好VM 并且激活 2 使用VM创建虚拟机 3 启动虚拟机 终端常用点 VNC的使用 麒麟上安装V
  • 如何在 CentOS/RHEL 和 Fedora 上设置 VNC 服务器(Linux 远程桌面访问)

    VNC 虚拟网络计算 服务器支持 Linux 系统的远程桌面访问 类似于MSTSC在窗户中 一般来说Linux管理员不喜欢使用Windows访问 但有时我们需要访问Linux的远程桌面 在这种情况下 我们需要在 Linux 系统上安装 vn
  • Mac 电脑python 升级3.7版本

    转自 https www jianshu com p 5f55997ab719 官网下载python3 7 并且安装https www python org downloads mac osx 本人电脑有多个版本的python 为了体验新版
  • 小米造车?年轻人的第一辆电动车?

    素来有着价格屠夫称号的 小米 终于要对电动车出手了 事件简讯 昨天下午 据 晚点LatePost 爆料 小米 已确定造车 并视其为战略级决策 不过具体形式和路径还未确定 或许仍有变数 一位知情人士称 小米造车或将由小米集团创始人雷军亲自带队
  • Android 如何以编程方式添加/配置 Exchange 设置?

    是我的问题还是我找不到任何有关如何以编程方式添加 配置 Microsoft Exchange 的示例 这好像是 客户经理 addAccount String accountType String authTokenType String r
  • 配置“--prefix”选项进行交叉编译

    我应该通过哪条路径 prefix进行交叉编译时的选项 我应该指定构建机器上的路径还是目标平台上的路径 假设我将代码构建到 home me arm build target fs usr 之后我将文件复制到我的目标平台 它们将位于 usr 我
  • phpstorm中如何设置行注释的样式

    如何将 PHPStorm 中行注释的默认样式更改为缩进级别而不是第一列 if condition At first column At indentation level 对于 Ctrl 行注释 位于 设置 gt 代码样式 gt PHP g
  • 当使用 CPPFLAGS 指定目录时./configure 无法找到头文件

    我正在尝试在 Mac OS X Mavericks 上构建 php gettext 模块 安装了 gettextbrew install gettext 并且已检查的头文件可在 usr local opt gettext ls usr lo
  • ExtJs 转 DJango url 查询参数

    好吧 这是一个很长的问题 我正在使用 ExtJS 和 Django 创建一个网站 我在互联网上搜索了如何在获取 IFrame 时向 url 添加查询参数 所以基本上我有这个在 ExtJS 中创建一个面板 其中有一个 html 页面 我希望能
  • 在 xCode 界面生成器中,是否可以使用 control+drag 将视图元素与文件所有者连接起来?

    通过 TightVNC 连接到 Mac Mini 来处理 iPhone 应用程序 Interface Builder 中用于将视图元素连接到文件所有者的控制 拖动操作不起作用 我没有看到连接线 当我将键盘 鼠标和显示器连接到 Mini 并直
  • Qt 的 sysroot 和前缀选项的实际示例是什么

    我正在查看可以运行的所有选项configureQt 提供的脚本 特别是 qt everywhere opensource src 5 2 0 经过大量搜索后 我确定这些东西充其量记录很少 所以我希望我能得到一些帮助 当我查看描述时prefi

随机推荐