Last active
January 31, 2023 06:29
-
-
Save baseely/ccac1d5fe13fade11e27bb6904f602c1 to your computer and use it in GitHub Desktop.
Shell script to quickly install a VNC server on a CentOS 8 / RHEL 8 node.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dnf groupinstall -y "Server wuth GUI" | |
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 - vncuser | |
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 vncuser -c "/usr/bin/vncserver %i -geometry 1280×1024" | |
PIDFile=/home/vncuser/.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