Scripting Deployment and Start-up on Linux

Follow

You can perform all the operations required to download and install VNC Connect on a target computer - and license, configure, and start VNC Server ready for connections - at the command line, making it easy to script deployment.

*You can only license VNC Server as part of the deployment process if you have an Enterprise subscription.

The example script below targets Debian and Red Hat-compatible Linux computers, but the same principles apply to all supported platforms.

For more information on VNC Server modes, click here.

############# Download #############
# Download and unpack the latest binary on a 64-bit Debian-compatible system:
curl -L -o VNC.deb https://downloads.realvnc.com/download/file/vnc.files/VNC-Server-Latest-Linux-x64.deb
# Download the latest binary on a 32-bit Debian-compatible system:
# curl -L -o VNC.deb https://downloads.realvnc.com/download/file/vnc.files/VNC-Server-Latest-Linux-x86.deb
# Download the latest binary on a 64-bit Red Hat-compatible system:
# curl -L -o VNC.rpm https://downloads.realvnc.com/download/file/vnc.files/VNC-Server-Latest-Linux-x64.rpm
# Download the latest binary on a 32-bit Red Hat-compatible system:
# curl -L -o VNC.rpm https://downloads.realvnc.com/download/file/vnc.files/VNC-Server-Latest-Linux-x86.rpm
############# Install VNC Server #############
# Install VNC Server on a Debian-compatible system (assuming download file named as above):
sudo apt install -y ./VNC.deb
# Install VNC Server on a Red Hat-compatible system:
# sudo yum install -y VNC.rpm
############# License VNC Server #############
# For any subscription, start VNC Server in Service Mode (see below) and sign in to the GUI using your RealVNC account credentials.
# Alternatively, for Enterprise subscription only, apply your license key. More information:
# man vnclicense
# Apply your license key, available from the Deployment page of your RealVNC account:
sudo vnclicense -add XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
# Optionally enable cloud connectivity for VNC Server in Service Mode (token available with key):
sudo vncserver-x11 -service -joinCloud <your-token>
############# Specify a VNC password for VNC Server #############
# Mandatory for Home subscription (except Raspberry Pi). Not required for Professional or Enterprise subscription. More information:
# man vncpasswd
# Specify a VNC password for VNC Server in Service Mode:
sudo vncpasswd -service
# Enterprise subscription only. Specify a VNC password for VNC Server in Virtual Mode:
vncpasswd -virtual
############# Enable domain users to connect to VNC Server using system credentials #############
# Recommended for Enterprise and Professional subscriptions (by default, only local password store is checked). More information:
# man vncinitconfig
# Share the common PAM configuration on a Debian-compatible system with VNC Server:
echo -e '@include common-auth\n@include common-account\n@include common-session' | sudo tee /etc/pam.d/vncserver.custom
# Share the common PAM configuration on a Red Hat-compatible system with VNC Server:
# echo -e 'auth include password-auth\naccount include password-auth\nsession include password-auth' | sudo tee /etc/pam.d/vncserver.custom
# Register the common PAM configuration with VNC Server:
echo 'PamApplicationName=vncserver.custom' | sudo tee -a /etc/vnc/config.d/common.custom
############# Configure and start VNC Server in Service Mode #############
# Mandatory for Home and Professional subscriptions. More information:
# man vncserver-x11-serviced
# Optionally change registered users and permissions (by default, root user and admin group have full access):
# echo 'Permissions=%admin:f,dev.acme.com\\johndoe:d,janedoe:v' | sudo tee -a /root/.vnc/config.d/vncserver-x11
# Optional for Enterprise subscription only. Change the listening port for direct connections (by default, 5900):
# echo 'RfbPort=4999' | sudo tee -a /root/.vnc/config.d/vncserver-x11

# Start VNC Server on a Linux system using systemd:
# sudo systemctl start vncserver-x11-serviced.service

# Restart VNC Server each time a Linux system is booted using systemd:
# sudo systemctl enable vncserver-x11-serviced.service
############# Prepare a system for VNC Server in Virtual Mode #############
# Enterprise subscription only, plus Home on Raspberry Pi.
# More information: https://help.realvnc.com/hc/en-us/articles/360004324217 # Install X11 dummy drive on Debian-compatible systems:
sudo apt install xserver-xorg-video-dummy
# Install X11 dummy drive on Redhat-compatible systems:
# sudo yum install xorg-x11-drv-dummy
# Configure VNC Server to use X11 dummy driver. More information: https://help.realvnc.com/hc/en-us/articles/360003474752
sudo vncinitconfig --enable-system-xorg # Note also the following: hostname must be resolvable, xauth on PATH, and iptables suitably configured.
############# Configure and start VNC Server in Virtual Mode #############
# Enterprise subscription only, plus Home on Raspberry Pi. The daemon may be more convenient; see below. More information:
# man vncserver-virtual
# Optionally change registered users and permissions (by default, user starting VNC Server has full access):
# echo 'Permissions=:f,dev.acme.com\\johndoe:d,janedoe:v' | tee -a ~/.vnc/config.d/Xvnc
# Optionally specify virtual desktop geometries (first is the default, largest is the maximum). Connected users can cycle between using xrandr:
# echo 'RandR=1280x800,800x600,1024x768,1200x900,1280x720,1800x1024' | tee -a ~/.vnc/config.d/Xvnc
# Start VNC Server on port 5900+<next-available-display>, for example 5901. Note, do not start as root user:
vncserver-virtual
############# Configure and start VNC Server in Virtual Mode daemon #############
# Enterprise subscription only, plus Home on Raspberry Pi. More information:
# man vncserver-virtuald
# Mandatory if SELinux is Enforcing. Turn Avahi service discovery off:
echo 'ServiceDiscoveryEnabled=false' | sudo tee -a /etc/vnc/config.d/Xvnc
# Recommended. Restrict registered users and permissions (by default, any user can connect using system credentials):
echo 'Permissions=root:f,%teachers:d,%pupils:v' | sudo tee -a /root/.vnc/config.d/vncserver-virtuald
# Optionally change the listening port (by default, 5999):
# echo 'DaemonPort=6051' | sudo tee -a /root/.vnc/config.d/vncserver-virtuald

# Start VNC Server on a Linux system using systemd:
# sudo systemctl start vncserver-virtuald.service

# Restart VNC Server each time a Linux system is booted using systemd:
# sudo systemctl enable vncserver-virtuald.service
Was this article helpful?
47 out of 117 found this helpful

Comments

0 comments

Please sign in to leave a comment.