Install VNC Server in Ubuntu 18.04

VNC or Virtual Network Computing is one of the most popular technologies for remote access to the desktop, which is used in Linux. Previously, very often to access a remote desktop in Linux was used by the VNC server x11vnc, but after moving Ubuntu to Wayland to configure X11vnc became difficult. But he has few alternatives, for example, TigerVNC, which we now consider.

Unlike X11vnc here you can’t connect to an already running session, and instead, every running process VNC server will create a working session on a separate virtual screen display server. Next we will consider how to install and configure VNC Server Ubuntu 18.04, and initial setup to get started.

Install VNC Server on Ubuntu 18.04

The VNC Protocol allows you to share a Desk, so you will need to have installed the desktop environment. In the edition of Ubuntu for desktop use the Gnome desktop. But if you try to install the program on the server, you first install the GUI.

To install VNC server in Ubuntu, run the following command:

sudo apt install tigervnc-standalone-server tigervnc-common tigervnc-xorg-extension tigervnc-viewer

You must also install terminal emulator xterm, it the program will use to run the test environment:

sudo apt install xterm

To start the server, use the command vncserver. The syntax is simple:

vncserver port:nomerge options

But her main options:

  • -dry-run – a test run take no real actions;
  • -verbose – enable more verbose output;
  • -useold – start VNC server only if it is not running;
  • -cleanstale – clean up remaining files after a previous run;
  • -localhost – only allow connections from the local computer;
  • -name – the name of the VNC server to be displayed when connecting, the default is host:display# (username);
  • -geometry – the screen resolution for the start-up environment, for example, 1024×768;
  • -depth – the color depth, the available values are 8, 15, 16, and 24;
  • -fg – do not run service in background and leave it attached to the terminal;
  • -autokill – automatically stop the server after connection is completed;
  • -xstartup program you want to use instead of the shell;
  • -list – a list of running servers.
  • -kill – terminate a running vnc server.

Now you can try running VNC Server:

vncserver -xstartup /usr/bin/xterm

When you first start the utility prompts you to enter a password which you can use to connect to the computer and enter the password to connect in view-only mode. The latter can be ignored. Please note that the utility must be run from a normal user, not superuser.

Utility does not only create the configuration, but will start the VNC server. View a list of running servers with the command:

vncserver -list

To complete a running VNC server, use the kill option and the ID of the display running the server from the previous command:

vncserver -kill :1

We started with TigerVNC working environment in the terminal, but now we need a full working Gnome desktop. To configure this, create a file ~/.vnc/xstartup with the following content:

#!/bin/sh
dbus-launch --exit-with-session gnome-session &

This is the script that starts the desktop environment Gnome, you can also start and other environments. Now running the VNC server appears in the list of available servers you can connect to it.

To demonstrate the use of other options, let’s run vncserver on the fourth virtual display with a screen resolution of 1024×768:

vncserver :1 -geometry 1024x768

Connecting to VNC server

First, on the local machine you can connect to the running VNC server with the command offered by the server after start:

vncviewer-SecurityTypes VncAuth -passwd /home/sergiy/.vnc/passwd :1

In this command we specify the type of authorization and transfer the file with a password that you created when you first start the VNC server. Before you open a remote connection.

You can also run vncviewer Ubuntu without any parameters, then the tool will open a graphical interface where you need to enter the ip address of the machine running the server and the display number or port:

Then you need to enter a password to connect and open the same window of the remote connection:

Insights

In this article, we discussed how to install VNC on Ubuntu 18.04, and how to customize the program to complete the work.

Source: losst.ru

(Visited 212 times, 1 visits today)