VNC (Remote Access) on Mint 19.x or 20.x

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
rene
Level 17
Level 17
Posts: 7754
Joined: Sun Mar 27, 2016 6:58 pm

VNC (Remote Access) on Mint 19.x or 20.x

Post by rene »

This is a slight update of viewtopic.php?t=320929 due to Mint 20.x losing the vnc4server / xvnc4viewer pair from the repositories. In the comments for that earlier post there's also a rough sketch of opening things up via SSH-tunnel over the internet; this post itself just deals with VNC.

First for a tiny bit of description since the issue tends to confuse new users: a VNC server is basically a full X server, just with input and output coming in from resp. going out over the network via VNC rather than from local input devices resp. local graphics adapters. This is to say that, normally, starting a VNC server starts a second and of the "main" X server independent X server; would normally be available on display :1 rather then the :0 of the standard X server. That secondary display one would need/want to configure from scratch with e.g. its own session manager or discrete set of X applications through ~/.vnc/xstartup --- but that's not what we will be doing: we will be installing a so-called "scraping" VNC server that shares the main display :0 over VNC instead.

For a desktop distribution such as Linux Mint this would tend to be more applicable to user desires even if you may want to look into the stand-alone server for e.g. graphical access to a VPS. For a scraping server there's a few alternatives available: for Mint 19.x there's x11vnc, TigerVNC and vnc4server and for Mint 20.x the first two of those. We will be using TigerVNC. Note that the also from the repositories available TightVNC while a fine VNC server in and of itself is/has not a scraping server so isn't applicable here.

The setup is really minimal and for those that like to access remote systems graphically rather than through e.g. SSH therefore quite convenient. Let me however immediately note that "remote" should in this preferably be considered to be within a LAN, i.e., behind a standard firewall and/or NAT-router. VNC is an old and not hugely security focussed protocol: if you'd want VNC access to your system(s) available from the internet you'd preferably set things up through an SSH tunnel which this tutorial will not go into even if only to not spoil the easy and straightforward setup on a LAN.

On the server, the system that is to be remotely graphically accessed, you install

Code: Select all

sudo apt-get install tigervnc-scraping-server
and on the client, the system that is to do said remote accessing, you install

Code: Select all

sudo apt-get install tigervnc-viewer
or, in fact, on said client use any of the multitude of remote access programs that support VNC such as RealVNC, Remmina, what have you; any of them could be more convenient for e.g. rescaling if native resolution is different between server and client. Clearly one should also feel free to install both on both systems if both systems are expected to be both server and client.

If tigervnc-scraping-server and tigervnc-viewer are the only server and viewer the system has installed things will be setup correctly automatically but if you have more pairs installed and the TigerVNC ones are not the last such installed pair, you may want to

Code: Select all

sudo update-alternatives --config x0vncserver
and the same for vncserver, vncviewer and vncpasswd to set your preferred ones(s) to the TigerVNC ones. Alternatively use explicitly x0tigervncserver, xtigervncviewer and tigervncpasswd rather than the generic names in what follows.

Starting the server without any form of authentication is easiest and done simply as, on the server,

Code: Select all

x0vncserver -SecurityTypes=none
which you may moreover of course also add as an e.g. desktop startup application to have it started always. Viewing from the client should be a simple matter of

Code: Select all

vncviewer <server>
in which <server> is an address or resolvable name for the server --- which you may again of course also feel free to turn into an e.g. desktop launcher on the client, with or without a spiffy icon.

Even on a LAN you may of course want password-based access instead, lest potentially any user on the client logs in over VNC as whichever user runs the VNC server on the server, and this is still about as easy. In that case first on the server generate a password into ~/.vnc/passwd with

Code: Select all

vncpasswd
I suggest to use the user's normal login password. Then start the VNC server with instead

Code: Select all

x0vncserver -PasswordFile=/home/<user>/.vnc/passwd
for the applicable user <user>. On the client this will cause the simple

Code: Select all

vncviewer <server>
to prompt for the password or you can start it as

Code: Select all

vncviewer -passwd ~/.vnc/passwd <server>
after either copying the ~/.vnc/passwd file from server to client or simply using vncpasswd with the same password also on the client. I'd as said not make even password-based VNC available directly from the internet without tunnelling things through SSH but on a LAN, most home-user LANs certainly, this should be all there is to it.

Hope this is useful.
Post Reply