Skip to content

Instantly share code, notes, and snippets.

@SegoCode
Created September 5, 2025 09:04
Show Gist options
  • Select an option

  • Save SegoCode/42735f36b15448dab413573892dc6e76 to your computer and use it in GitHub Desktop.

Select an option

Save SegoCode/42735f36b15448dab413573892dc6e76 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Helper functions
print_section() {
echo ""
echo "====================================="
echo "$1"
echo "====================================="
}
print_status() {
echo ""
echo "✅ $1"
echo ""
}
print_warning() {
echo ""
echo "⚠️ $1"
echo ""
}
# Step 7: Install Perl dependencies (BEFORE KasmVNC)
print_section "Step 7: Installing Perl dependencies for KasmVNC..."
sudo apt-get update || exit 1
sudo apt-get install -y \
libswitch-perl \
libyaml-tiny-perl \
libhash-merge-simple-perl \
liblist-moreutils-perl \
libdatetime-perl \
libdatetime-timezone-perl || exit 1
print_status "Perl dependencies installed successfully!"
# Step 8: Download and install KasmVNC
print_section "Step 8: Installing KasmVNC..."
wget https://github.com/kasmtech/KasmVNC/releases/download/v1.3.4/kasmvncserver_bookworm_1.3.4_amd64.deb -O kasmvncserver.deb || exit 1
sudo apt-get install -y ./kasmvncserver.deb || exit 1
rm kasmvncserver.deb
print_status "KasmVNC installed successfully!"
# Step 9: Fix any broken dependencies and add user to ssl-cert group
print_section "Step 9: Fixing dependencies and configuring user permissions..."
sudo apt-get install -f || exit 1
sudo adduser $USER ssl-cert || true # Idempotent, ignore if already added
print_status "User permissions configured successfully!"
# Steps 10-11: Run under sg ssl-cert to apply group without logout
print_warning "Applying group changes without logout using 'sg ssl-cert'..."
sg ssl-cert bash -c '
print_section() {
echo ""
echo "====================================="
echo "$1"
echo "====================================="
}
print_status() {
echo ""
echo "✅ $1"
echo ""
}
print_warning() {
echo ""
echo "⚠️ $1"
echo ""
}
# Step 10: Set VNC password
print_section "Step 10: Setting up VNC password..."
print_warning "You will need to enter your VNC password twice when prompted."
vncpasswd -u $USER -w || exit 1
# Step 11: Start VNC server
print_section "Step 11: VNC server setup..."
print_warning "Starting VNC server (if prompted, select option 2 for XFCE)..."
vncserver -select-de xfce || exit 1
print_status "VNC server started! Check ~/.vnc/*.log for access URLs (e.g., https://<IP>:5901)."
echo "To access: Find your IP with '\''ip addr show'\'', open in browser, accept cert, login with your username and VNC password."
' || { print_warning "sg failed (rare) - try logging out/in and re-run, or run 'sg ssl-cert' manually."; exit 1; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment