VNC is a graphical desktop sharing system to access another computer remotely. When installed on server with Ubuntu 16.04 it provides desktop access to the server.
Requirements:
Virtualization server with Ubuntu 16.04 installed.
Root access via SSH.
- When connected to the server, update current packages list and upgrade them:
- Install the required packages for the VNC connection (choose one):
If you want to install all possible packages:
apt-get install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
If you want to install only the essential packages:
apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
- Essential step is to stop and then disable the NetworkManager service. With this service active the server would not be accessible:
systemctl stop NetworkManager.service
systemctl disable NetworkManager.service
4. Install vncserver packets:
apt-get install vnc4server
- After the vncserver packets are installed, start the vncserver service. After initiation, the console will require you to provide a password for VNC connection and repeat it (up to 8 characters):
You will receive the following message:
xauth: file /root/.Xauthority does not exist
New 'localhost:1 (root)' desktop is localhost:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost:1.log
- Afterwards stop the vncserver service, since configuration files have been created, but we have to adjust few more things:
- Edit the ~/.vnc/xstartup file (for this we use nano, however you can use alternate text editor).
The mentioned file contents should be edited into following:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -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" &
x-window-manager &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
- After saving changes to ~/.vnc/xstartup, start the vncserver service once more:
- Now the VNC access to the server is possible. In addition we recommend to set up your crontab, so that after server reboot the vncservice would start automatically:
9.1. In the bottom of opened cron task file add the following line:
@reboot /usr/bin/vncserver :1
After saving the changes to file everything is complete. For accessing VNC via various VNC clients use the following address:
server_ip:5901 (123.456.789.0:5901) and the password that you have set during 5th step.