Skip to content

Instantly share code, notes, and snippets.

@bpmct
Last active January 22, 2024 20:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpmct/4e51d7092089f278c91f53e344749b6c to your computer and use it in GitHub Desktop.
Save bpmct/4e51d7092089f278c91f53e344749b6c to your computer and use it in GitHub Desktop.
#!/bin/bash
# This has been tested on the aws-linux Coder template, which runs Ubuntu Focal
# Check if LXDE is installed
if ! dpkg -s lxde &> /dev/null; then
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y lxde
else
echo "LXDE is already installed."
fi
# Check if vncserver is installed
if ! dpkg -s kasmvncserver &> /dev/null; then
cd /tmp
wget https://github.com/kasmtech/KasmVNC/releases/download/v1.1.0/kasmvncserver_focal_1.1.0_amd64.deb
sudo apt install -y ./kasmvncserver_focal_1.1.0_amd64.deb
else
echo "VNC Server is already installed."
fi
sudo addgroup $USER ssl-cert
# Coder port-forwarding from dashboard only supports HTTP
sudo bash -c 'cat > /etc/kasmvnc/kasmvnc.yaml <<EOF
network:
protocol: http
ssl:
require_ssl: false
udp:
public_ip: 127.0.0.1
EOF'
# This password is not used since we start the server without auth.
# The server is protected via the Coder session token / tunnel
# and does not listen publicly on the VM
echo -e "password\npassword\n" | vncpasswd -wo -u $USER
# Start the server :)
sudo su -u $USER bash -c 'vncserver -select-de "lxde" -disableBasicAuth'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment