Last active
March 21, 2026 21:45
-
-
Save 0xAungkon/15ed16c454097f56ea5f786af2632d21 to your computer and use it in GitHub Desktop.
Vnc Server
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
| # !/bin/sh | |
| # update and install necessary packages | |
| sudo apt-get update ; | |
| sudo apt-get install xfce4 xfce4-goodies tigervnc-standalone-server tigervnc-common curl git wget xfce4 fonts-cantarell fonts-firacode lightdm qt5ct ristretto parole engrampa thunar-archive-plugin mousepad mate-calc atril xfce4-taskmanager xfce4-screenshooter xcape xfce4-power-manager-plugins xfce4-whiskermenu-plugin xdg-user-dirs-gtk tmux dbus-x11 -y | |
| # install themes | |
| cd /tmp ; | |
| git clone https://gitlab.com/kalilinux/packages/kali-themes.git --depth 1; | |
| cd kali-themes; | |
| sudo cp -a share /usr/ ; | |
| sudo cp -a etc / ; | |
| # configure xfce4 | |
| rm -rf ~/.config/xfce4 && xfce4-session-logout --reboot --fast; | |
| # configure themes | |
| xfconf-query -c xsettings -p /Net/ThemeName -s Kali-Dark; | |
| xfconf-query -c xsettings -p /Net/IconThemeName -s Flat-Remix-Blue-Dark; | |
| xfconf-query -c xfwm4 -p /general/theme -s Kali-Dark; | |
| xfce4-panel -r | |
| # install noVNC | |
| sudo git clone https://github.com/novnc/noVNC.git /opt/noVNC | |
| sudo git clone https://github.com/novnc/websockify /opt/noVNC/utils/websockify | |
| sudo cp /opt/noVNC/vnc.html /opt/noVNC/index.html | |
| # generate self-signed certificates for secure noVNC connections | |
| sudo mkdir -p /opt/noVNC/certs | |
| sudo openssl req -x509 -newkey rsa:4096 -keyout /opt/noVNC/certs/key.pem -out /opt/noVNC/certs/cert.pem -days 365 -nodes -subj "/CN=localhost" | |
| # set VNC password | |
| # configure systemd services for noVNC and VNC server | |
| cat <<EOF | sudo tee /etc/systemd/system/novnc.service | |
| [Unit] | |
| Description=noVNC Service | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| ExecStart=/opt/noVNC/utils/novnc_proxy --vnc localhost:5901 --listen 6480 | |
| Restart=on-failure | |
| User=root | |
| [Install] | |
| WantedBy=multi-user.target | |
| EOF | |
| cat <<EOF | sudo tee /etc/systemd/system/novnc-secure.service | |
| [Unit] | |
| Description=noVNC Service | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| ExecStart=/opt/noVNC/utils/novnc_proxy --vnc localhost:5901 --cert /opt/noVNC/certs/cert.pem --key /opt/noVNC/certs/key.pem --listen 6443 | |
| Restart=on-failure | |
| User=root | |
| [Install] | |
| WantedBy=multi-user.target | |
| EOF | |
| sudo tee /etc/systemd/system/vncserver@.service <<EOF | |
| [Unit] | |
| Description=TigerVNC Server for %i on display :1 | |
| After=network.target | |
| [Service] | |
| Type=forking | |
| User=%i | |
| WorkingDirectory=/home/%i | |
| ExecStartPre=-/usr/bin/vncserver -kill :1 | |
| ExecStart=/usr/bin/vncserver :1 -geometry 1280x720 -depth 24 | |
| ExecStop=/usr/bin/vncserver -kill :1 | |
| Restart=on-failure | |
| [Install] | |
| WantedBy=multi-user.target | |
| EOF | |
| # enable and start the services | |
| USER_NAME=$(whoami) | |
| sudo systemctl daemon-reload | |
| sudo systemctl enable novnc.service | |
| sudo systemctl enable novnc-secure.service | |
| sudo systemctl enable vncserver@${USER_NAME}.service | |
| vncpasswd | |
| sudo systemctl start novnc.service | |
| sudo systemctl start novnc-secure.service | |
| sudo systemctl start vncserver@${USER_NAME}.service | |
| echo "Setup complete! You can access your VNC server at localhost:5901 and noVNC at http://localhost:6480 (insecure) or https://localhost:6443 (secure)." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment