Saturday, September 19, 2020

Quick VNC setup

I started with these instructions. Note the session you get is not what is on the console. It is a separate one like you would get with Windows Terminal Server. This may be a feature or issue given your needs. 

Those instructions boil down to the step below (with added tweaks). Replace <USER> with your user name.

Log out of any X Windows sessions and log in via ssh

You may need to clean up these old files / folders. (See this.) If they exist remove them with rm -fr as in rm -rf /tmp/.X0-lock.

  • /home/<USER>/.vnc
  • /tmp/.X*

Run these commands as root or add sudo in front of each. 

yum groupinstall "GNOME Desktop"

yum install -y tigervnc-server xorg-x11-fonts-Type1

su - <USER>



firewall-cmd --add-port=5901/tcp --permanent

cp /lib/systemd/system/vncserver@.service  /etc/systemd/system/vncserver@:1.service

vi /etc/systemd/system/vncserver@\:1.service

Instead of their instructions change the file contents to this


Description=Remote desktop service (VNC)




# Clean any existing files in /tmp/.X11-unix environment

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

ExecStart=/sbin/runuser -l <USER>  -c "/usr/bin/vncserver %i -geometry 1920x1080"

PIDFile=/home/<USER> /.vnc/

ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'


systemctl daemon-reload

systemctl start vncserver@:1

systemctl status vncserver@:1 -l

Output should look like 

● vncserver@:1.service - Remote desktop service (VNC)

   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)

   Active: inactive (dead) since Sat 2020-09-19 18:29:07 CDT; 6min ago

  Process: 12636 ExecStop=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)

  Process: 12563 ExecStart=/sbin/runuser -l dea -c /usr/bin/vncserver %i -geometry 1920x1080 (code=exited, status=0/SUCCESS)

  Process: 12550 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)

 Main PID: 12563 (code=exited, status=0/SUCCESS)

Sep 19 18:29:04 systemd[1]: Starting Remote desktop service (VNC)...

Sep 19 18:29:04 systemd[1]: Started Remote desktop service (VNC).

reboot (just to be sure it all starts automatically)

Install a client like RealVNC

Note the above instructions leave out the fact you need add the port 5901 in the connection like:

Note too you will probably need to open port 5901 on your clients firewall as well.

No comments:

Post a Comment