1. Make sure you have the GNOME desktop installed
The desktop version is installed by default, and the server version needs to be installed manually and started
# apt install ubuntu-gnome-desktop
# systemctl set-default multi-user.target
$ startx
2. Install VNC
Do not install tigervncserver
To install this standalone, there will be a little difference (the following -localhost no is not recognized)
sudo apt-get install tigervnc-standalone-server
3. Configure VNC Server
If you want to log in with a certain user such as demo, use su to switch to this user.
If you want to log in as root, you can directly use the root account to operate.
# su - demo
demo@demoserver:~$ vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
The above command will generate a passwd file in the ~/.vnc/ directory. Inside is the encrypted password.
Then you need to cd to the ~/.vnc directory and create a new xstartup file
touch xstartup
Enter the following:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &
The function is to run these commands when the vncserver starts to start the desktop program.
4. Start VNC Server
vncserver :1 -geometry 1920x1080 -localhost no
Note: If an error message similar to the following appears:
You need to manually create this file, and then start the VNC Server again
view all vnc sessions
vncserver -list
To close a session you can use the following command
vncserver -kill :1
5. Remote connection
You can use vncviewer
Remote address input ip:port
Such as: 192.168.1.11:5901
For the specific port number, you can check the RFB PROT in the result returned by vncserver -list