Skip to content

Instantly share code, notes, and snippets.

@wilkersoncs
Created September 18, 2020 17:36
Show Gist options
  • Save wilkersoncs/132edbdc0255045e6f11c949d66915d8 to your computer and use it in GitHub Desktop.
Save wilkersoncs/132edbdc0255045e6f11c949d66915d8 to your computer and use it in GitHub Desktop.
Install script for VNC on CentOS 8
# From https://www.linuxtechi.com/install-configure-vnc-server-centos8-rhel8/
dnf groupinstall -y "workstation"
systemctl set-default graphical
set -p "Reboot and proceed"
echo "WaylandEnable=false" >> /etc/gdm/custom.conf
setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
dnf install tigervnc-server tigervnc-server-module -y
su - user1
echo "Enter n for view-only password"
vncpasswd
cat << EOF > /etc/systemd/system/[email protected]
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l user1 -c "/usr/bin/vncserver %i -geometry 1280×1024"
PIDFile=/home/user1/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start vncserver@:1.service
systemctl enable vncserver@:1.service
firewall-cmd --permanent --add-port=5901/tcp
firewall-cmd --reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment