Two Methods of Ubuntu 20.04 Desktop VNC Remote Control

Original link: https://mianao.info/2022/06/09/363504

After installing Ubuntu 20.04 desktop, because it already has Gnome, the requirements for remote control are different from those of the general desktop-free server version. After my search and testing, there are two methods to achieve:

System comes with remote control

1. Settings – Sharing – Screen Sharing

Turn on the screen sharing switch, set the access password, you can connect automatically, so you don’t need to click on the machine to confirm:

2.dconf Change system configuration

Open a terminal and enter the following command to install the dconf-editor system configuration editor:

 sudo apt-get install dconf-editor

After installation, the newly added dconf application can be found in the application;
There will be such a warning when launching the app, so use it with care and don’t modify any options other than those mentioned in this article!
Find requlre-encryption according to the path /org/gnome/desktop/remote-access and change the original default open state to closed

3. Download the VNC Viewer client connection

Under Windows, you can choose a green version of standalone EXE that does not need to be installed:
Client download: https://www.realvnc.com/en/connect/download/viewer/

Run the client, enter the IP and port number 5900 :

VNC Server Remote Control

Ubuntu 20.04 desktop has its own desktop Gnome by default, but I have configured it many times and found that the remote screen is grayed out after the connection, and the mouse is a black x. The reason has not been found yet.
So I choose another option:

1. Install gnome-session-flashback :

 sudo apt-get install gnome-session-flashback

According to the prompt, it may be necessary to install gdm3, if not, don’t worry about it.

2. Install VNC Server

 sudo apt-get install tigervnc-standalone-server #要安装tigervnc-standalone 版本,普通版本无法输入其他指令,如-list

Install if prompted otherwise: sudo apt-get install tigervnc-xorg-extension

After installation, run the vncserver command (do not execute it under root):

 You will require a password to access your desktops. Password: Verify: Would you like to enter a view-only password (y/n)? n /usr/bin/xauth: file /home/typhoon/.Xauthority does not exist New 'server2.typhoon.org:1 (typhoon)' desktop at :1 on machine server2.typhoon.org Starting applications specified in /etc/X11/Xvnc-session Log file is /home/typhoon/.vnc/server2.typhoon.org:1.log Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/typhoon/.vnc/passwd :1 to connect to the VNC server.

You will be prompted to enter and confirm the password, which is not related to the system password. And whether to set it to only view passwords, remember to select N.

3. Configure the xstartup file:

Edit xstartup:

 vi ~/.vnc/xstartup

Modify the content in the xstartup file, and test the normal configuration as follows:

 #!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS export XKL_XMODMAP_DISABLE=1 export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME" export XDG_MENU_PREFIX="gnome-flashback-" [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey #设置背景色vncconfig -iconic & gnome-terminal & #连接后会直接打开一个terminal窗口nautilus & #连接后会直接打开一个文件窗口gnome-session --session=gnome-flashback-metacity --disable-acceleration-check &

Change permissions after modification:

 sudo chmod +x ~/.vnc/xstartup

4. Start and stop VNC Server:

 vncserver -localhost no #启动VNC,单独vncserver 命令会导致远程无法连接vncserver -kill :1 #关闭5901 端口VNC 服务vncserver -list #查看连接端口vncpasswd #重设密码

5. VNC Viewer Client Remote Control

Download the client as linked above.
After running the client, enter the IP and port number 5901 (check the connection port according to vncserver -list , :1=5901), and enter the password as prompted.

Attached Linux system related commands:

 sudo useradd -r -m -s /bin/bash username #新建一个用户su - username #切换用户sudo passwd #设置密码sudo ufw disable #关闭防火墙,如有异常可关闭防火墙,20.04 我没关闭也可正常连接sudo ufw status #查看防火墙状态

Recommend a cheap VPS that I have been using for 5 years and feel fairly stable and reliable

Vultr: Welcome to use the referral link, there is a reward of $100 for new users to recharge, thank you! https://www.vultr.com/?ref=9125823-8H
Although there may be IP blocks, the computer rooms in Europe, America and Asia can be switched at will. The minimum monthly fee for the US computer room is $3.5 : 512M memory and 500G traffic.

This article is reprinted from: https://mianao.info/2022/06/09/363504
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.