On the remote host
Install vino
sudo apt update
sudo apt install vino
Enable VNC
sudo ln -s ../vino-server.service /usr/lib/systemd/user/graphical-session.target.wants
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino require-encryption false
Open the following file
code /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml
and add
<key name='enabled' type='b'>
<summary>Enable remote access to the desktop</summary>
<description>
If true, allows remote access to the desktop via the RFB
protocol. Users on remote machines may then connect to the
desktop using a VNC viewer.
</description>
<default>false</default>
</key>
Compile the above file
sudo glib-compile-schemas /usr/share/glib-2.0/schemas
Set the VNC login password
gsettings set org.gnome.Vino authentication-methods "['vnc']"
gsettings set org.gnome.Vino vnc-password $(echo -n '12345678'|base64)
Reboot
To start VNC automatically
gsettings set org.gnome.Vino enabled true
mkdir -p ~/.config/autostart
code ~/.config/autostart/vino-server.desktop
and add the following to the file
[Desktop Entry]
Type=Application
Name=Vino VNC server
Exec=/usr/lib/vino/vino-server
NoDisplay=true
The VNC server should be ready. To access from a client machine, install a VNC client application, such as gvncviewer on ubuntu and vnc viewer on android, and connect to the VNC server with IP address ( can be found by ifconfig ), and login with the password.
reference link
https://www.jianshu.com/p/e670a9a26989https://www.jianshu.com/p/e670a9a26989