This brief tutorial shows students and new users how to install Virtual Network Computing (VNC) server on Ubuntu 16.04 | 18.04 servers to allow remote connection via VNC protocol…
VNC is a graphical desktop sharing system that allows users to connect remotely to a system with keyboard and mouse access… This is an open source alternative to Microsoft Remote Desktop Protocol…
When you’re ready to get started with installing and configure VNC server on Ubuntu, follow the steps below:
Step 1: Install Desktop Environment
By default Ubuntu servers don’t come with a desktop environment and VNC requires desktop environment to function… Since we don’t want to install a full-blown desktop environment, a better alternative is a lightweight environment called Xfce..
To intall Xfce, run the commands below
sudo apt update sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils
Step 2: Install VNC Server
Now that a lightweight desktop environment is installed, run the commands below to install VNC server… There many VNC servers available, including TightVNC, x11vnc and TigerVNC…. for this post, we’re going to be using TigerVNC...
To install TigerVNC, run the commands below:
sudo apt install tigervnc-standalone-server tigervnc-common
After installing TigerVNC, run the commands below to setup an initial setup including creating a password to access the desktops…
That should output similar message as below:
You will require a password to access your desktops. Password: Verify: Would you like to enter a view-only password (y/n)? n New 'ubuntu1804:1 (richrd)' desktop at :1 on machine ubuntu1804 Starting applications specified in /etc/X11/Xvnc-session Log file is /home/richrd/.vnc/ubuntu1804:1.log Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/richrd/.vnc/passwd :1 to connect to the VNC server. vncserver: Failed command '/etc/X11/Xvnc-session': 256! =================== tail -15 /home/richrd/.vnc/ubuntu1804:1.log =================== Starting applications specified in /etc/X11/Xvnc-session has failed. Maybe try something simple first, e.g., tigervncserver -xstartup /usr/bin/xterm
After that, vncserver command will create a password file and store it in your ~/.vnc folder…
Step 3: Configure VNC Server
Now that VNC server is installed, run the commands below to configure it…
vncserver -kill :1
Then create a startup config file..
add the lines into the file and save..
#!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS exec startxfce4
Run the commands below after the above..
chmod u+x ~/.vnc/xstartup
Next, create a systemd file..
sudo nano /etc/systemd/system/vncserver@.service
Then add the lines below into the file and save..
[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=simple User=richard PAMName=login PIDFile=/home/%u/.vnc/%H%i.pid ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :' ExecStart=/usr/bin/vncserver :%i -geometry 1440x900 -alwaysshared -fg ExecStop=/usr/bin/vncserver -kill :%i [Install] WantedBy=multi-user.target
After saving the file run the commands below to reload systemd config…
sudo systemctl daemon-reload
Start and enable VNC server
sudo systemctl start firstname.lastname@example.org sudo systemctl enable email@example.com
After check to see if VNC is started and running…
sudo systemctl status firstname.lastname@example.org
You should see something similar to the one below
● email@example.com - Remote desktop service (VNC) Loaded: loaded (/etc/systemd/system/vncserver@.service; indirect; vendor preset: enabled) Active: active (running) since Mon 2019-02-04 15:22:07 CST; 17s ago Main PID: 14025 (vncserver) Tasks: 0 (limit: 4663) CGroup: /firstname.lastname@example.org ‣ 14025 /usr/bin/perl /usr/bin/vncserver :1 -geometry 1440x900 -alwaysshared -fg Feb 04 15:22:06 ubuntu1804 systemd: Starting Remote desktop service (VNC)... Feb 04 15:22:07 ubuntu1804 systemd: pam_unix(login:session): session opened for user richrd by (uid=0) Feb 04 15:22:07 ubuntu1804 systemd: Started Remote desktop service (VNC). Feb 04 15:22:07 ubuntu1804 systemd: pam_unix(login:session): session opened for user richrd by (uid=0)
Now you’re all set… Find a VNC client and attempt to the server…
A good VNC to use it VNC Viewer from RealVNC… Install it and connect to the server…
Type in the password you created above and connect
Congratulations! You’ve successfully installed, configure and connected to a VNC server on Ubuntu 16.04 | 18.04
You may also like the post below: