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

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
rene
Level 20
Level 20
Posts: 12212
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.
FIGG
Level 1
Level 1
Posts: 8
Joined: Sun Jul 30, 2017 8:03 pm

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

Post by FIGG »

Thank you for posting this, Rene! This is very helpful!! I would hope that since Gnome added support for RDP in their latest release that Mint would do the same but I guess we'll have to wait and see.

Thanks!

James
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

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

Post by rene »

Thanks for the comment.

RDP is a proprietary protocol developed by Microsoft -- and one does start to wonder when e.g. Red Hat will finally-finally-finally learn that while certainly you can make proprietary Microsoft technology work in Linux, you can not have it consistently continue to work over a few Windows-sides updates by Microsoft to said technology (at which point the Windows masses start pouring in FUD-ing Linux for not being able to do "basic things").

Wine and Proton, .Net/Mono, Samba, NTFS -- and shortly then RDP. VNC sucks in all the same ways for years and years on end at least...
User avatar
Ahmed_samy
Level 3
Level 3
Posts: 121
Joined: Sun Mar 06, 2022 8:24 am
Location: Egypt

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

Post by Ahmed_samy »

rene wrote: Thu Jun 17, 2021 2:04 pm ,............

I want to be able to access it from anywhere in the world
"I know you think you know what I said, but what you need to know is, I didn't say what I meant" Stolen🌚
remember to do

Code: Select all

inxi -Fxxxrz
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

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

Post by rene »

There is as mentioned a rough sketch of how to do so in the comments of the previous version of this post; viewtopic.php?t=320929. The "rough" isn't in fact even very rough, but is for the most part general networking, i.e., concerns addressability of the to be controlled system from the internet and opening/forwarding ports; Is unrelated to VNC as such.
Qwinn
Level 1
Level 1
Posts: 6
Joined: Sat Jan 20, 2024 1:29 pm

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

Post by Qwinn »

Wanted to thank you for this. Worked fine on LM 21.3 cinnamon.

The only thing that was missing was that you need to add `-localhost no` to the `x0vncserver` command, otherwise the server only listens to the 5900 port on 127.0.0.1 which is pretty useless.
Post Reply

Return to “Tutorials”