From 84fc96cd21274569c3d965e33971c2c30c20113b Mon Sep 17 00:00:00 2001 From: itiligent <94789708+itiligent@users.noreply.github.com> Date: Wed, 19 Jul 2023 15:55:28 +1000 Subject: [PATCH] rebased for v1.5.2 --- 1-setup.sh | 674 ++++++++++++++++++++++++++++ 2-install-guacamole.sh | 529 ++++++++++++++++++++++ 3-install-nginx.sh | 127 ++++++ 4a-install-ssl-self-signed-nginx.sh | 256 +++++++++++ 4b-install-ssl-letsencrypt-nginx.sh | 179 ++++++++ ACTIVE-DIRECTORY-HOW-TO.md | 70 +++ LICENSE | 662 +++++++++++++++++++++++++++ README.md | 77 ++++ add-auth-duo.sh | 58 +++ add-auth-ldap.sh | 76 ++++ add-auth-totp.sh | 42 ++ add-fail2ban.sh | 261 +++++++++++ add-smtp-relay-o365.sh | 123 +++++ add-ssl-guac-gaucd.sh | 93 ++++ backup-guac.sh | 65 +++ branding.jar | Bin 0 -> 24217 bytes upgrade-guac.sh | 347 ++++++++++++++ useful-commands.txt | 56 +++ 18 files changed, 3695 insertions(+) create mode 100644 1-setup.sh create mode 100644 2-install-guacamole.sh create mode 100644 3-install-nginx.sh create mode 100644 4a-install-ssl-self-signed-nginx.sh create mode 100644 4b-install-ssl-letsencrypt-nginx.sh create mode 100644 ACTIVE-DIRECTORY-HOW-TO.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 add-auth-duo.sh create mode 100644 add-auth-ldap.sh create mode 100644 add-auth-totp.sh create mode 100644 add-fail2ban.sh create mode 100644 add-smtp-relay-o365.sh create mode 100644 add-ssl-guac-gaucd.sh create mode 100644 backup-guac.sh create mode 100644 branding.jar create mode 100644 upgrade-guac.sh create mode 100644 useful-commands.txt diff --git a/1-setup.sh b/1-setup.sh new file mode 100644 index 0000000..2179740 --- /dev/null +++ b/1-setup.sh @@ -0,0 +1,674 @@ +#!/bin/bash +###################################################################################################################### +# Guacamole appliance setup script +# For Ubuntu / Debian / Raspbian +# David Harrop +# April 2023 +####################################################################################################################### + +# To install latest snapshot: +# wget https://raw.githubusercontent.com/itiligent/Guacamole-Setup/main/1-setup.sh && chmod +x 1-setup.sh && ./1-setup.sh + +# If something isn't working? +# tail -f /var/log/syslog /var/log/tomcat*/*.out /var/log/mysql/*.log guac-setup/guacamole_${GUAC_VERSION}_setup.log + +# This whole install routine could be collated into one huge script, but it is far easier to manage and maintain by +# breaking up the different stages of the install into at least 4 separate scripts as follows... +# 1-setup.sh is a central script that manages all inputs, options and sequences other included 'install' scripts. +# 2-install-guacamole is the main guts of the whole build. This script downloads and builds Guacamole from source. +# 3-install-nginx.sh automatically installs and configures Nginx to work as an http port 80 front end to Guacamole +# 4a-install-self-signed-nginx.sh sets up the new Nginx/Guacamole front end with self signed SSL certificates. +# 4b-install-ssl-letsencrypt-nginx.sh sets up Nginx with public SSL certificates from LetsEncrypt. +# Scripts with "add" in their name can be run post guacamole setup to add optional features not included in the main install + +clear + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +if [[ $EUID -eq 0 ]]; then + echo + echo -e "${LRED}This script must NOT be run as root" 1>&2 + echo -e ${NC} + exit 1 +fi + +# Check to see if previous build/install files exist, stop and check to be safe. +if [ "$(find . -maxdepth 1 \( -name 'guacamole-*' -o -name 'mysql-connector-j-*' \))" != "" ]; then + # Script branding header + echo + echo -e "${GREYB}Itiligent Virtual Desktop Appliance Setup." + echo -e " ${LGREEN}Powered by Guacamole" + echo + echo + + echo -e "${LRED}Possible previous temp files detected in current build path. Please review and remove old 'guacamole-*' & 'mysql-connector-j-*' files before proceeding.${GREY}" 1>&2 + echo + exit 1 +fi + +####################################################################################################################### +# Core setup ########################################################################################################## +####################################################################################################################### + +#Setup download and temp directory paths +USER_HOME_DIR=$(eval echo ~${SUDO_USER}) +DOWNLOAD_DIR=$USER_HOME_DIR/guac-setup +DB_BACKUP_DIR=$USER_HOME_DIR/mysqlbackups/ +TMP_DIR=$DOWNLOAD_DIR/tmp + +# Github download branch +GITHUB="https://raw.githubusercontent.com/itiligent/Guacamole-Setup/main/" + +#Version of Guacamole to install +GUAC_VERSION="1.5.2" + +# Set preferred Apache CDN download link +GUAC_SOURCE_LINK="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUAC_VERSION}" + +# MySQL Connector/J version +MYSQLJCON="8.0.33" + +# Check for the latest version of Tomcat currently supported by the Linux distro +if [[ $(apt-cache show tomcat10 2>/dev/null | egrep "Version: 10" | wc -l) -gt 0 ]]; then + TOMCAT_VERSION="tomcat10" +elif [[ $(apt-cache show tomcat9 2>/dev/null | egrep "Version: 9" | wc -l) -gt 0 ]]; then + TOMCAT_VERSION="tomcat9" +elif [[ $(apt-cache show tomcat8 2>/dev/null | egrep "Version: 8.[5-9]" | wc -l) -gt 0 ]]; then + TOMCAT_VERSION="tomcat8" +elif [[ $(apt-cache show tomcat7 2>/dev/null | egrep "Version: 8" | wc -l) -gt 0 ]]; then + TOMCAT_VERSION="tomcat7" +else + # Default to current version + TOMCAT_VERSION="tomcat9" +fi +# Override Apache Tomcat version here. +# TOMCAT_VERSION="tomcat9" + +# Install log Location +LOG_LOCATION="${DOWNLOAD_DIR}/guacamole_${GUAC_VERSION}_setup.log" + +# Guacamole default install URL +GUAC_URL=http://localhost:8080/guacamole/ + +# Depending on the Linux distro, required libraries have varied names. Standardising with names makes adapting +# to other distros easier. +source /etc/os-release +OS_FLAVOUR=$ID +OS_VERSION=$VERSION +JPEGTURBO="" +LIBPNG="" + +# Get the default route interface IP +DEFAULT_IP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) + +# Get an initial dns search suffix for use as a starting default for a local dns domain prompt value, we prompt to update this later +get_domain_suffix() { + echo "$1" | awk '{print $2}' +} +# Search for "search" and "domain" entries in /etc/resolv.conf +search_line=$(grep -E '^search[[:space:]]+' /etc/resolv.conf) +domain_line=$(grep -E '^domain[[:space:]]+' /etc/resolv.conf) +# Check if both "search" and "domain" lines exist +if [ -n "$search_line" ] && [ -n "$domain_line" ]; then + # Both "search" and "domain" lines exist, extract the domain suffix from both + search_suffix=$(get_domain_suffix "$search_line") + domain_suffix=$(get_domain_suffix "$domain_line") + # Print the domain suffix that appears first + if [ ${#search_suffix} -lt ${#domain_suffix} ]; then + DOMAIN_SUFFIX=$search_suffix + else + DOMAIN_SUFFIX=$domain_suffix + fi +elif [ -n "$search_line" ]; then + # If only "search" line exists + DOMAIN_SUFFIX=$(get_domain_suffix "$search_line") +elif [ -n "$domain_line" ]; then + # If only "domain" line exists + DOMAIN_SUFFIX=$(get_domain_suffix "$domain_line") +else + # If no "search" or "domain" lines found + DOMAIN_SUFFIX="local" +fi + +####################################################################################################################### +# Silent setup options - adding true/false or specific values below prevents prompt at install ######################## +####################################################################################################################### +SERVER_NAME="" # Preferred server hostname +LOCAL_DOMAIN="" # Local DNS space in use +INSTALL_MYSQL="" # Install locally (true/false) +SECURE_MYSQL="" # Apply mysql secure configuration tool (true/false) +MYSQL_HOST="" # leave blank for localhost default, only specify for remote servers +MYSQL_PORT="" # If blank default is 3306 +GUAC_DB="" # If blank default is guacamole_db +GUAC_USER="" # if blank default is guacamole_user +GUAC_PWD="" # Should not be blank as this may break some aspects of install +MYSQL_ROOT_PWD="" # Should not be blank as this may break some aspects of install +INSTALL_TOTP="" # TOTP MFA extension (true/false) +INSTALL_DUO="" # DUO MFA extension (cant be installed simultaneously with TOTP, true/false) +INSTALL_LDAP="" # Active Directory extension (true/false) +INSTALL_NGINX="" # Install and configure Guacamole behind Nginx reverse proxy (http port 80 only, true/false) +PROXY_SITE="" # Local DNS name for reverse proxy and self signed ssl certificates +SELF_SIGN="" # Add self signed SSL support to Nginx (Let's Encrypt not available with this, true/false) +CERT_COUNTRY="AU" # 2 country character code only, must not be blank +CERT_STATE="Victoria" # Optional to change, must not be blank +CERT_LOCATION="Melbourne" # Optional to change, must not be blank +CERT_ORG="Itiligent" # Optional to change, must not be blank +CERT_OU="I.T." # Optional to change, must not be blank +CERT_DAYS="3650" # Number of days until self signed certificate expiry +LETS_ENCRYPT="" # Add Lets Encrypt public SSL support for Nginx (self signed SSL certs not available with this, true/false) +LE_DNS_NAME="" # Public DNS name to bind with Lets Encrypt certificates +LE_EMAIL="" # Webmaster/admin email for Lets Encrypt +BACKUP_EMAIL="" # Email address for backup notifications +BACKUP_RETENTION="30" # How many days to keep backups for +RDP_SHARE_LABEL="" # Custom system name to show in windows explorer. (eg RDPshare on "ServerName") +RDP_DRIVE_LABEL="RDP Share" # Custom drive file system label (eg "RDPshare" on ServerName) +RDP_PRINTER_LABEL="RDP Printer" # Custom RDP printer name + +# Script branding header +echo +echo -e "${GREYB}Itiligent Virtual Desktop Appliance Setup." +echo -e " ${LGREEN}Powered by Guacamole" +echo +echo + +# Setup directory locations +mkdir -p $DOWNLOAD_DIR +mkdir -p $DB_BACKUP_DIR +mkdir -p $TMP_DIR + +####################################################################################################################### +# Download GitHub setup scripts. To prevent overwrite, comment out lines of any scripts you have edited. ############## +####################################################################################################################### + +# Download config scripts and setup items from GitHub +cd $DOWNLOAD_DIR +echo -e "${GREY}Downloading setup files...${DGREY}" +wget -q --show-progress ${GITHUB}2-install-guacamole.sh -O 2-install-guacamole.sh +wget -q --show-progress ${GITHUB}3-install-nginx.sh -O 3-install-nginx.sh +wget -q --show-progress ${GITHUB}4a-install-ssl-self-signed-nginx.sh -O 4a-install-ssl-self-signed-nginx.sh +wget -q --show-progress ${GITHUB}4b-install-ssl-letsencrypt-nginx.sh -O 4b-install-ssl-letsencrypt-nginx.sh +# Grab Guacamole manual add on/upgrade scripts +wget -q --show-progress ${GITHUB}add-auth-duo.sh -O add-auth-duo.sh +wget -q --show-progress ${GITHUB}add-auth-ldap.sh -O add-auth-ldap.sh +wget -q --show-progress ${GITHUB}add-auth-totp.sh -O add-auth-totp.sh +wget -q --show-progress ${GITHUB}add-smtp-relay-o365.sh -O add-smtp-relay-o365.sh +wget -q --show-progress ${GITHUB}upgrade-guac.sh -O upgrade-guac.sh +# Grab backup and security hardening scripts +wget -q --show-progress ${GITHUB}backup-guac.sh -O backup-guac.sh +wget -q --show-progress ${GITHUB}add-ssl-guac-gaucd.sh -O add-ssl-guac-gaucd.sh +wget -q --show-progress ${GITHUB}add-fail2ban.sh -O add-fail2ban.sh +# Grab a (customisable) branding extension +wget -q --show-progress ${GITHUB}branding.jar -O branding.jar +chmod +x *.sh +sleep 2 +clear + +# Script branding header +echo +echo -e "${GREYB}Itiligent Virtual Desktop Appliance Setup." +echo -e " ${LGREEN}Powered by Guacamole" +echo +echo + +# Pause to optionally customise downloaded scripts before any actual install actions +echo -e "${LYELLOW}Ctrl+Z now to exit if you wish to edit any 1-setup.sh options for an unattended install." + +# Now prompt for sudo to get ready for a hostname change, then while we are here also set perms for sudo and non sudo access to tmp setup files +echo -e "${LGREEN}" +sudo chmod -R 770 $TMP_DIR +sudo chown -R $SUDO_USER:root $TMP_DIR + +####################################################################################################################### +# Begin install menu prompts ########################################################################################## +####################################################################################################################### + +# We need a default hostname value available to apply even if we do not want to change the hostname. This approach allows the +# user to simply hit enter at the prompt without this creating a blank entry into the /etc/hosts file. +# hostnames and matching DNS entries are essential for implementing SSL successfully. +if [[ -z ${SERVER_NAME} ]]; then + echo -e "${LYELLOW}Update Linux system HOSTNAME [Enter to keep: ${HOSTNAME}]${LGREEN}" + read -p " Enter new HOSTNAME : " SERVER_NAME + if [[ "${SERVER_NAME}" = "" ]]; then + SERVER_NAME=$HOSTNAME + fi + echo + sudo hostnamectl set-hostname $SERVER_NAME &>>${LOG_LOCATION} + sudo sed -i '/127.0.1.1/d' /etc/hosts &>>${LOG_LOCATION} + echo '127.0.1.1 '${SERVER_NAME}'' | sudo tee -a /etc/hosts &>>${LOG_LOCATION} + sudo systemctl restart systemd-hostnamed &>>${LOG_LOCATION} +else + echo + sudo hostnamectl set-hostname $SERVER_NAME &>>${LOG_LOCATION} + sudo sed -i '/127.0.1.1/d' /etc/hosts &>>${LOG_LOCATION} + echo '127.0.1.1 '${SERVER_NAME}'' | sudo tee -a /etc/hosts &>>${LOG_LOCATION} + sudo systemctl restart systemd-hostnamed &>>${LOG_LOCATION} +fi + +if [[ -z ${LOCAL_DOMAIN} ]]; then + echo -e "${LYELLOW}Update Linux LOCAL DNS DOMAIN [Enter to keep: ${DOMAIN_SUFFIX}]${LGREEN}" + read -p " Enter FULL LOCAL DOMAIN NAME: " LOCAL_DOMAIN + if [[ "${LOCAL_DOMAIN}" = "" ]]; then + LOCAL_DOMAIN=$DOMAIN_SUFFIX + fi + echo + sudo sed -i "/${DEFAULT_IP}/d" /etc/hosts + sudo sed -i '/domain/d' /etc/resolv.conf + sudo sed -i '/search/d' /etc/resolv.conf + # Update the /etc/hosts file with the new domain values + echo ''${DEFAULT_IP}' '${SERVER_NAME}.${LOCAL_DOMAIN} ${SERVER_NAME}'' | sudo tee -a /etc/hosts &>>${LOG_LOCATION} + #Update resolv.conf with new domain and search suffix values + echo 'domain '${LOCAL_DOMAIN}'' | sudo tee -a /etc/resolv.conf &>>${LOG_LOCATION} + echo 'search '${LOCAL_DOMAIN}'' | sudo tee -a /etc/resolv.conf &>>${LOG_LOCATION} + sudo systemctl restart systemd-hostnamed &>>${LOG_LOCATION} +else + echo + sudo sed -i "/${DEFAULT_IP}/d" /etc/hosts + sudo sed -i '/domain/d' /etc/resolv.conf + sudo sed -i '/search/d' /etc/resolv.conf + # Update the /etc/hosts file with the new domain values + echo ''${DEFAULT_IP}' '${SERVER_NAME}.${LOCAL_DOMAIN} ${SERVER_NAME}'' | sudo tee -a /etc/hosts &>>${LOG_LOCATION} + #Update resolv.conf with new domain and search suffix values + echo 'domain '${LOCAL_DOMAIN}'' | sudo tee -a /etc/resolv.conf &>>${LOG_LOCATION} + echo 'search '${LOCAL_DOMAIN}'' | sudo tee -a /etc/resolv.conf &>>${LOG_LOCATION} + sudo systemctl restart systemd-hostnamed &>>${LOG_LOCATION} +fi + +# After updating the hostname and domain names, we can now use a refreshed starting value for the local FQDN and Guacamole share label names. +DEFAULT_FQDN=$SERVER_NAME.$LOCAL_DOMAIN +if [[ -z ${RDP_SHARE_LABEL} ]]; then + RDP_SHARE_LABEL=$SERVER_NAME +fi + +clear + +# Script branding header +echo +echo -e "${GREYB}Itiligent Virtual Desktop Appliance Setup." +echo -e " ${LGREEN}Powered by Guacamole" +echo +echo + +# Prompt the user to install MySQL +echo -e "${LGREEN}MySQL setup options:${GREY}" +if [[ -z ${INSTALL_MYSQL} ]]; then + echo -e -n "SQL: Install MySQL? (for a remote MySQL Server select 'n') [Y/n] [default y]: ${GREY}" + read PROMPT + if [[ ${PROMPT} =~ ^[Nn]$ ]]; then + INSTALL_MYSQL=false + else + INSTALL_MYSQL=true + fi +fi + +# Prompt the user to apply the Mysql secure installation locally +if [ -z ${SECURE_MYSQL} ] && [ "${INSTALL_MYSQL}" = true ]; then + echo -e -n "${GREY}SQL: Apply MySQL secure installation settings to LOCAL db? [Y/n] [default y]: ${GREY}" + read PROMPT + if [[ ${PROMPT} =~ ^[Nn]$ ]]; then + SECURE_MYSQL=false + else + SECURE_MYSQL=true + fi +fi + +# Prompt the user to apply the Mysql secure installation to remote db +if [ -z ${SECURE_MYSQL} ] && [ "${INSTALL_MYSQL}" = false ]; then + echo -e -n "${GREY}SQL: Apply MySQL secure installation settings to REMOTE db? [y/N] [default n]: ${GREY}" + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + SECURE_MYSQL=true + else + SECURE_MYSQL=false + fi +fi + +# Get additional MYSQL values +if [ "${INSTALL_MYSQL}" = false ]; then + [ -z "${MYSQL_HOST}" ] && + read -p "SQL: Enter MySQL server hostname or IP: " MYSQL_HOST + [ -z "${MYSQL_PORT}" ] && + read -p "SQL: Enter MySQL server port [3306]: " MYSQL_PORT + [ -z "${GUAC_DB}" ] && + read -p "SQL: Enter Guacamole database name [guacamole_db]: " GUAC_DB + [ -z "${GUAC_USER}" ] && + read -p "SQL: Enter Guacamole user name [guacamole_user]: " GUAC_USER +fi + +# Checking if a mysql host given, if not set a default +if [ -z "${MYSQL_HOST}" ]; then + MYSQL_HOST="localhost" +fi + +# Checking if a mysql port given, if not set a default +if [ -z "${MYSQL_PORT}" ]; then + MYSQL_PORT="3306" +fi + +# Checking if a database name given, if not set a default +if [ -z "${GUAC_DB}" ]; then + GUAC_DB="guacamole_db" +fi + +# Checking if a mysql user given, if not set a default +if [ -z "${GUAC_USER}" ]; then + GUAC_USER="guacamole_user" +fi + +# Get Guacamole User password, confirm correct password entry and prevent blank passwords +if [ -z "${GUAC_PWD}" ]; then + while true; do + read -s -p "SQL: Enter ${MYSQL_HOST}'s MySQL ${GUAC_USER} password: " GUAC_PWD + echo + read -s -p "SQL: Confirm ${MYSQL_HOST}'s MySQL ${GUAC_USER} password: " PROMPT2 + echo + [ "${GUAC_PWD}" = "${PROMPT2}" ] && [ "${GUAC_PWD}" != "" ] && [ "${PROMPT2}" != "" ] && break + echo -e "${LRED}Passwords don't match or can't be null. Please try again.${GREY}" 1>&2 + done +fi + +# Get MySQL root password, confirm correct password entry and prevent blank passwords +if [ -z "${MYSQL_ROOT_PWD}" ]; then + while true; do + read -s -p "SQL: Enter ${MYSQL_HOST}'s MySQL root password: " MYSQL_ROOT_PWD + echo + read -s -p "SQL: Confirm ${MYSQL_HOST}'s MySQL root password: " PROMPT2 + echo + [ "${MYSQL_ROOT_PWD}" = "${PROMPT2}" ] && [ "${MYSQL_ROOT_PWD}" != "" ] && [ "${PROMPT2}" != "" ] && break + echo -e "${LRED}Passwords don't match or can't be null. Please try again.${GREY}" 1>&2 + done +fi + +# Prompt for preferred backup notification email address +if [[ -z ${BACKUP_EMAIL} ]]; then + while true; do + read -p "SQL: Enter email address for SQL backup messages [Enter to skip]: " BACKUP_EMAIL + [ "${BACKUP_EMAIL}" = "" ] || [ "${BACKUP_EMAIL}" != "" ] && break + # Rather than allow a blank value, un-comment to alternately force user to enter an explicit value instead + # [ "${BACKUP_EMAIL}" != "" ] && break + # echo -e "${LRED}You must enter an email address. Please try again.${GREY}" 1>&2 + done +fi + +# If no backup notification email address is given, enter a default value +if [ -z ${BACKUP_EMAIL} ]; then + BACKUP_EMAIL="backup-email@yourdomain.com" +fi + +echo +# Prompt the user if they would like to install TOTP MFA +echo -e "${LGREEN}Guacamole authentication extension options:${GREY}" +if [[ -z "${INSTALL_TOTP}" ]] && [[ "${INSTALL_DUO}" != true ]]; then + echo -e -n "AUTH: Install TOTP? (choose 'n' if you want Duo) [y/N]? [default n]: " + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + INSTALL_TOTP=true + INSTALL_DUO=false + else + INSTALL_TOTP=false + fi +fi + +# Prompt the user if they would like to install Duo MFA +if [[ -z "${INSTALL_DUO}" ]] && [[ "${INSTALL_TOTP}" != true ]]; then + echo -e -n "${GREY}AUTH: Install Duo? [y/N] [default n]: " + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + INSTALL_DUO=true + INSTALL_TOTP=false + else + INSTALL_DUO=false + fi +fi + +# We can't install TOTP and Duo at the same time (option not supported by Guacamole) +if [[ "${INSTALL_TOTP}" = true ]] && [[ "${INSTALL_DUO}" = true ]]; then + echo -e "${LRED}GUAC MFA: TOTP and Duo cannot be installed at the same time.${GREY}" 1>&2 + exit 1 +fi + +# Prompt the user if they would like to install Duo MFA +if [[ -z "${INSTALL_LDAP}" ]]; then + echo -e -n "${GREY}AUTH: Install LDAP? [y/N] [default n]: " + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + INSTALL_LDAP=true + else + INSTALL_LDAP=false + fi +fi + +echo +# Prompt for Guacamole front end reverse proxy option +echo -e "${LGREEN}Nginx reverse proxy options:${GREY}" +if [[ -z ${INSTALL_NGINX} ]]; then + echo -e -n "REV PROXY: Protect Guacamole behind Nginx reverse proxy [Y/n]? [default y]: " + read PROMPT + if [[ ${PROMPT} =~ ^[Nn]$ ]]; then + INSTALL_NGINX=false + else + INSTALL_NGINX=true + fi +fi + +# We must assign a DNS name for the new proxy site +if [[ -z ${PROXY_SITE} ]] && [[ "${INSTALL_NGINX}" = true ]]; then + while true; do + read -p "REV PROXY: Enter proxy local DNS name? [Enter to use ${DEFAULT_FQDN}]: " PROXY_SITE + [ "${PROXY_SITE}" = "" ] || [ "${PROXY_SITE}" != "" ] && break + # Rather than allow the default value below, un-comment to alternately force user to enter an explicit name instead + # [ "${PROXY_SITE}" != "" ] && break + # echo -e "${LRED}You must enter a proxy site DNS name. Please try again.${GREY}" 1>&2 + done +fi + +# If no proxy site dns name is given, lets assume the default FQDN is the proxy site name +if [ -z "${PROXY_SITE}" ]; then + PROXY_SITE="${DEFAULT_FQDN}" +fi + +# Prompt for self signed SSL reverse proxy option +if [[ -z ${SELF_SIGN} ]] && [[ "${INSTALL_NGINX}" = true ]]; then + # Prompt the user to see if they would like to install self signed SSL support for Nginx, default of no + echo -e -n "REV PROXY: Add self signed SSL support to Nginx? [y/N]? (choose 'n' for Let's Encrypt)[default n]: " + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + SELF_SIGN=true + else + SELF_SIGN=false + fi +fi + +# Optional prompt to assign the self sign SSL certificate a custom expiry date, un-comment to force a manual entry +#if [ "${SELF_SIGN}" = true ]; then +# read - p "PROXY: Enter number of days till SSL certificate expires [default 3650]: " CERT_DAYS +#fi + +# If no self sign SSL certificate expiry given, lets assume a generous 10 year default certificate expiry +if [ -z "${CERT_DAYS}" ]; then + CERT_DAYS="3650" +fi + +# Prompt for Let's Encrypt SSL reverse proxy configuration option +if [[ -z ${LETS_ENCRYPT} ]] && [[ "${INSTALL_NGINX}" = true ]] && [[ "${SELF_SIGN}" = "false" ]]; then + echo -e -n "REV PROXY: Add Let's Encrypt SSL support to Nginx reverse proxy [y/N] [default n]: ${GREY}" + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + LETS_ENCRYPT=true + else + LETS_ENCRYPT=false + fi +fi + +# Prompt for Let's Encrypt public dns name +if [[ -z ${LE_DNS_NAME} ]] && [[ "${LETS_ENCRYPT}" = true ]]; then + while true; do + read -p "REV PROXY: Enter the FQDN for your public proxy site : " LE_DNS_NAME + [ "${LE_DNS_NAME}" != "" ] && break + echo -e "${LRED}You must enter a public DNS name. Please try again.${GREY}" 1>&2 + done +fi + +# Prompt for Let's Encrypt admin email +if [[ -z ${LE_EMAIL} ]] && [[ "${LETS_ENCRYPT}" = true ]]; then + while true; do + read -p "REV PROXY: Enter the email address for Let's Encrypt notifications : " LE_EMAIL + [ "${LE_EMAIL}" != "" ] && break + echo -e "${LRED}You must enter an email address. Please try again.${GREY}" 1>&2 + done +fi + +####################################################################################################################### +# Start global setup actions ######################################################################################### +####################################################################################################################### + +# Ubuntu and Debian each require different dependency packages. +# To adapt this script to other distros, research the correct library package names and reference these with their variable +# names shown here: https://guacamole.apache.org/doc/gug/installing-guacamole.html +clear +echo +echo -e "${GREYB}Itiligent Virtual Desktop Appliance Setup." +echo -e " ${LGREEN}Powered by Guacamole" +echo +echo +echo -e "${LGREEN}Beginning Guacamole setup...${GREY}" +echo +echo -e "${GREY}Checking Linux distro specific dependencies..." +if [[ $OS_FLAVOUR == "ubuntu" ]] || [[ $OS_FLAVOUR == "ubuntu"* ]]; then # potentially expand out distro choices here + JPEGTURBO="libjpeg-turbo8-dev" + LIBPNG="libpng-dev" + # Just in case this repo is not added by default in the distro + sudo add-apt-repository -y universe &>>${LOG_LOCATION} +elif [[ $OS_FLAVOUR == "debian" ]] || [[ $OS_FLAVOUR == "raspbian" ]]; then # expand distro choices here if required + JPEGTURBO="libjpeg62-turbo-dev" + LIBPNG="libpng-dev" +fi +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Because the below scripts may be run manually after install, we need to sync them +# with our global variables or any setup prompt choices we made. This way we can run them +# later and they will all work as a set without any manual changes. +sed -i "s|MYSQL_HOST=|MYSQL_HOST='${MYSQL_HOST}'|g" $DOWNLOAD_DIR/backup-guac.sh +sed -i "s|MYSQL_PORT=|MYSQL_PORT='${MYSQL_PORT}'|g" $DOWNLOAD_DIR/backup-guac.sh +sed -i "s|GUAC_USER=|GUAC_USER='${GUAC_USER}'|g" $DOWNLOAD_DIR/backup-guac.sh +sed -i "s|GUAC_PWD=|GUAC_PWD='${GUAC_PWD}'|g" $DOWNLOAD_DIR/backup-guac.sh +sed -i "s|GUAC_DB=|GUAC_DB='${GUAC_DB}'|g" $DOWNLOAD_DIR/backup-guac.sh +sed -i "s|DB_BACKUP_DIR=|DB_BACKUP_DIR='${DB_BACKUP_DIR}'|g" $DOWNLOAD_DIR/backup-guac.sh +sed -i "s|BACKUP_EMAIL=|BACKUP_EMAIL='${BACKUP_EMAIL}'|g" $DOWNLOAD_DIR/backup-guac.sh +sed -i "s|BACKUP_RETENTION=|BACKUP_RETENTION='${BACKUP_RETENTION}'|g" $DOWNLOAD_DIR/backup-guac.sh +sed -i "s|CERT_COUNTRY=|CERT_COUNTRY='${CERT_COUNTRY}'|g" $DOWNLOAD_DIR/add-ssl-guac-gaucd.sh +sed -i "s|CERT_STATE=|CERT_STATE='${CERT_STATE}'|g" $DOWNLOAD_DIR/add-ssl-guac-gaucd.sh +sed -i "s|CERT_LOCATION=|CERT_LOCATION='${CERT_LOCATION=}'|g" $DOWNLOAD_DIR/add-ssl-guac-gaucd.sh +sed -i "s|CERT_ORG=|CERT_ORG='${CERT_ORG}'|g" $DOWNLOAD_DIR/add-ssl-guac-gaucd.sh +sed -i "s|CERT_OU=|CERT_OU='${CERT_OU}'|g" $DOWNLOAD_DIR/add-ssl-guac-gaucd.sh + +# Export the relevant variable selections to child install scripts +export BACKUP_EMAIL=$BACKUP_EMAIL +export CERT_COUNTRY=$CERT_COUNTRY +export CERT_LOCATION="${CERT_LOCATION}" +export CERT_ORG="${CERT_ORG}" +export CERT_OU="${CERT_OU}" +export CERT_STATE="${CERT_STATE}" +export DOWNLOAD_DIR="${DOWNLOAD_DIR}" +export GUAC_DB=$GUAC_DB +export GUAC_PWD="${GUAC_PWD}" +export GUAC_SOURCE_LINK=$GUAC_SOURCE_LINK +export GUAC_URL=$GUAC_URL +export GUAC_USER=$GUAC_USER +export GUAC_VERSION=$GUAC_VERSION +export INSTALL_DUO=$INSTALL_DUO +export INSTALL_LDAP=$INSTALL_LDAP +export INSTALL_MYSQL=$INSTALL_MYSQL +export INSTALL_TOTP=$INSTALL_TOTP +export JPEGTURBO=$JPEGTURBO +export LE_DNS_NAME=$LE_DNS_NAME +export LE_EMAIL=$LE_EMAIL +export LIBPNG=$LIBPNG +export LOG_LOCATION=$LOG_LOCATION +export MYSQL_HOST=$MYSQL_HOST +export MYSQL_PORT=$MYSQL_PORT +export MYSQL_ROOT_PWD="${MYSQL_ROOT_PWD}" +export MYSQLJCON=$MYSQLJCON +export PROXY_SITE=$PROXY_SITE +export SECURE_MYSQL=$SECURE_MYSQL +export TMP_DIR=$TMP_DIR +export TOMCAT_VERSION=$TOMCAT_VERSION +export RDP_SHARE_LABEL="${RDP_SHARE_LABEL}" +export RDP_DRIVE_LABEL="${RDP_DRIVE_LABEL}" +export RDP_PRINTER_LABEL="${RDP_PRINTER_LABEL}" + +# Run the Guacamole install script +sudo -E ./2-install-guacamole.sh +if [ $? -ne 0 ]; then + echo -e "${LRED}2-install-guacamole.sh FAILED. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}Guacamole install complete\nhttp://${PROXY_SITE}:8080/guacamole - login user/pass: guacadmin/guacadmin\n${LYELLOW}***Be sure to change the password***${GREY}" +fi + +# Add a Guacamole database backup (mon-fri 12:00am) into cron +crontab -l >cron_1 +# Remove existing entry to allow multiple runs +sed -i '/# backup guacamole/d' cron_1 +# Create the job +echo "0 0 * * 1-5 ${DOWNLOAD_DIR}/backup-guac.sh # backup guacamole" >>cron_1 +# Overwrite the cron settings and cleanup +crontab cron_1 +rm cron_1 + +####################################################################################################################### +# Start optional setup actions ###################################################################################### +####################################################################################################################### + +# Install Nginx reverse proxy front end to Guacamole if option is selected +if [ "${INSTALL_NGINX}" = true ]; then + sudo -E ./3-install-nginx.sh + echo -e "${LGREEN}Nginx install complete\nhttp://${PROXY_SITE} - login user/pass: guacadmin/guacadmin\n${LYELLOW}***Be sure to change the password***${GREY}" +fi + +# Apply self signed SSL certificates to Nginx reverse proxy if option is selected +if [[ "${INSTALL_NGINX}" = true ]] && [[ "${SELF_SIGN}" = true ]]; then + sudo -E ./4a-install-ssl-self-signed-nginx.sh ${PROXY_SITE} ${CERT_DAYS} + echo -e "${LGREEN}Self signed certificate configured for Nginx \n${LYELLOW}https:${LGREEN}//${PROXY_SITE} - login user/pass: guacadmin/guacadmin\n${LYELLOW}***Be sure to change the password***${GREY}" +fi + +# Apply Let's Encrypt SSL certificates to Nginx reverse proxy if option is selected +if [[ "${INSTALL_NGINX}" = true ]] && [[ "${LETS_ENCRYPT}" = true ]]; then + sudo -E ./4b-install-ssl-letsencrypt-nginx.sh + echo -e "${LGREEN}Let's Encrypt SSL configured for Nginx \n${LYELLOW}https:${LGREEN}//${LE_DNS_NAME} - login user/pass: guacadmin/guacadmin\n${LYELLOW}***Be sure to change the password***${GREY}" +fi + +# Duo Settings reminder - If Duo is selected you can't login to Guacamole at all until this extension is fully configured +if [ $INSTALL_DUO == "true" ]; then + echo + echo -e "${LYELLOW}Reminder: Duo requires extra account specific info configured in the\n/etc/guacamole/guacamole.properties file before you can log in to Guacamole." + echo -e "See https://guacamole.apache.org/doc/gug/duo-auth.html" +fi + +# LDAP Settings reminder, LDAP auth is not active functional until the config is complete +if [ $INSTALL_LDAP == "true" ]; then + echo + echo -e "${LYELLOW}Reminder: LDAP requires that your LDAP directory configuration match the exact format\nadded to the /etc/guacamole/guacamole.properties file before LDAP auth will be active." + echo -e "See https://guacamole.apache.org/doc/gug/ldap-auth.html" +fi + +# Final tidy up +mv $USER_HOME_DIR/1-setup.sh $DOWNLOAD_DIR +sudo rm -R $TMP_DIR + +# Done +echo +printf "${LGREEN}Guacamole ${GUAC_VERSION} install complete! \n${NC}" +echo -e ${NC} diff --git a/2-install-guacamole.sh b/2-install-guacamole.sh new file mode 100644 index 0000000..218c81e --- /dev/null +++ b/2-install-guacamole.sh @@ -0,0 +1,529 @@ +#!/bin/bash +####################################################################################################################### +# Guacamole main build script +# For Ubuntu / Debian / Raspbian +# David Harrop +# April 2023 +# Special thanks to MysticRyuujin for much of the guac install outline here +# pls see https://github.com/MysticRyuujin/guac-install for more +####################################################################################################################### + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +# Pre-seed MySQL install values +if [ "${INSTALL_MYSQL}" = true ]; then + debconf-set-selections <<<"mysql-server mysql-server/root_password password ${MYSQL_ROOT_PWD}" + debconf-set-selections <<<"mysql-server mysql-server/root_password_again password ${MYSQL_ROOT_PWD}" +fi + +# Checking if (any kind of) mysql-client or compatible command installed. This is useful for existing mariadb server +if [ "${INSTALL_MYSQL}" = true ]; then + MYSQL="default-mysql-server default-mysql-client mysql-common" +elif [ -x "$(command -v mysql)" ]; then + MYSQL="" +else + MYSQL="default-mysql-client" +fi + +# Don't do annoying prompts during apt installs +echo -e "${GREY}Updating base Linux OS..." +export DEBIAN_FRONTEND=noninteractive +sudo apt-get update -qq &>>${LOG_LOCATION} +sudo apt-get upgrade -qq -y &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Install Guacamole build dependencies. +echo -e "${GREY}Installing dependencies required for building Guacamole, this might take a few minutes..." +apt-get -qq -y install ${JPEGTURBO} ${LIBPNG} ufw htop pwgen wget crudini expect build-essential libcairo2-dev libtool-bin uuid-dev libavcodec-dev libavformat-dev libavutil-dev \ + libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libwebsockets-dev libpulse-dev libssl-dev \ + libvorbis-dev libwebp-dev ghostscript ${MYSQL} ${TOMCAT_VERSION} &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" +fi + +# Install Postfix with default settings for smtp email relay +echo +echo -e "${GREY}Installing SMTP email for backup email notifications and alerts, see separate SMTP relay configuration script..." +DEBIAN_FRONTEND="noninteractive" apt-get install postfix mailutils -qq -y &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" +fi +service postfix restart + +# Download Guacamole Server +echo +echo -e "${GREY}Downloading Guacamole source files..." +wget -q --show-progress -O guacamole-server-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/source/guacamole-server-${GUAC_VERSION}.tar.gz +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-server-${GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/source/guacamole-server-${GUAC_VERSION}.tar.gz${GREY}" + exit 1 +else + tar -xzf guacamole-server-${GUAC_VERSION}.tar.gz +fi +echo -e "${LGREEN}Downloaded guacamole-server-${GUAC_VERSION}.tar.gz${GREY}" + +# Download Guacamole Client +wget -q --show-progress -O guacamole-${GUAC_VERSION}.war ${GUAC_SOURCE_LINK}/binary/guacamole-${GUAC_VERSION}.war +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-${GUAC_VERSION}.war" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-${GUAC_VERSION}.war${GREY}" + exit 1 +fi +echo -e "${LGREEN}Downloaded guacamole-${GUAC_VERSION}.war${GREY}" + +# Download Guacamole authentication extensions +wget -q --show-progress -O guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz" + exit 1 +else + tar -xzf guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz +fi +echo -e "${LGREEN}Downloaded guacamole-auth-jdbc-${GUAC_VERSION}.tar.gz${GREY}" + +# Download TOTP extension +if [ "${INSTALL_TOTP}" = true ]; then + wget -q --show-progress -O guacamole-auth-totp-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-auth-totp-${GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz" + exit 1 + else + tar -xzf guacamole-auth-totp-${GUAC_VERSION}.tar.gz + fi + echo -e "${LGREEN}Downloaded guacamole-auth-totp-${GUAC_VERSION}.tar.gz${GREY}" +fi + +# Download DUO extension +if [ "${INSTALL_DUO}" = true ]; then + wget -q --show-progress -O guacamole-auth-duo-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-auth-duo-${GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz" + exit 1 + else + tar -xzf guacamole-auth-duo-${GUAC_VERSION}.tar.gz + fi + echo -e "${LGREEN}Downloaded guacamole-auth-duo-${GUAC_VERSION}.tar.gz${GREY}" +fi + +# Download LDAP extension +if [ "${INSTALL_LDAP}" = true ]; then + wget -q --show-progress -O guacamole-auth-ldap-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-auth-ldap-${GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz" + exit 1 + else + tar -xzf guacamole-auth-ldap-${GUAC_VERSION}.tar.gz + fi + echo -e "${LGREEN}Downloaded guacamole-auth-ldap-${GUAC_VERSION}.tar.gz${GREY}" +fi + +# Download MySQL connector/j +wget -q --show-progress -O mysql-connector-j-${MYSQLJCON}.tar.gz https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-${MYSQLJCON}.tar.gz +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download mysql-connector-j-${MYSQLJCON}.tar.gz" 1>&2 + echo -e "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-${MYSQLJCON}}.tar.gz${GREY}" + exit 1 +else + tar -xzf mysql-connector-j-${MYSQLJCON}.tar.gz +fi +echo -e "${LGREEN}Downloaded mysql-connector-j-${MYSQLJCON}.tar.gz${GREY}" +echo -e "Source download complete.${GREY}" + +# Option to pause script here as we might want to make final tweaks to source code just before compiling +#echo -e "${LYELLOW}" +#read -p $'Script paused for (optional) tweaking of source before building. Enter to Continue...\n' +#echo -e "${GREY}" + +# Add customised RDP share names and printer labels, remove Guacamole default labelling +sudo sed -i -e 's/IDX_CLIENT_NAME, "Guacamole RDP"/IDX_CLIENT_NAME, "'"${RDP_SHARE_LABEL}"'"/' ${DOWNLOAD_DIR}/guacamole-server-${GUAC_VERSION}/src/protocols/rdp/settings.c +sudo sed -i -e 's/IDX_DRIVE_NAME, "Guacamole Filesystem"/IDX_CLIENT_NAME, "'"${RDP_DRIVE_LABEL}"'"/' ${DOWNLOAD_DIR}/guacamole-server-${GUAC_VERSION}/src/protocols/rdp/settings.c +sudo sed -i -e 's/IDX_PRINTER_NAME, "Guacamole Printer"/IDX_PRINTER_NAME, "'"${RDP_PRINTER_LABEL}"'"/' ${DOWNLOAD_DIR}/guacamole-server-${GUAC_VERSION}/src/protocols/rdp/settings.c + +# Make Guacamole directories +rm -rf /etc/guacamole/lib/ +rm -rf /etc/guacamole/extensions/ +mkdir -p /etc/guacamole/lib/ +mkdir -p /etc/guacamole/extensions/ + +# Fix for #196 see https://github.com/MysticRyuujin/guac-install/issues/196 +mkdir -p /usr/sbin/.config/freerdp +chown daemon:daemon /usr/sbin/.config/freerdp + +# Fix for #197 see https://github.com/MysticRyuujin/guac-install/issues/197 +mkdir -p /var/guacamole +chown daemon:daemon /var/guacamole + +# Make and install guacd (Guacamole-Server) +cd guacamole-server-${GUAC_VERSION}/ +echo +echo -e "${GREY}Compiling Guacamole-Server from source with with GCC $(gcc --version | head -n1 | grep -oP '\)\K.*' | awk '{print $1}'), this might take a few minutes...${GREY}" + +# Fix for warnings see #222 https://github.com/MysticRyuujin/guac-install/issues/222 +export CFLAGS="-Wno-error" + +# Configure Guacamole Server source +./configure --with-systemd-dir=/etc/systemd/system &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo "Failed to configure guacamole-server" + echo "Trying again with --enable-allow-freerdp-snapshots" + ./configure --with-systemd-dir=/etc/systemd/system --enable-allow-freerdp-snapshots + if [ $? -ne 0 ]; then + echo "Failed to configure guacamole-server - again" + exit + fi +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +echo -e "${GREY}Running make and building the Guacamole-Server application..." +make &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +echo -e "${GREY}Installing Guacamole-Server..." +make install &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi +ldconfig + +# Move files to correct install locations (guacamole-client & Guacamole authentication extensions) +cd .. +mv -f guacamole-${GUAC_VERSION}.war /etc/guacamole/guacamole.war +mv -f guacamole-auth-jdbc-${GUAC_VERSION}/mysql/guacamole-auth-jdbc-mysql-${GUAC_VERSION}.jar /etc/guacamole/extensions/ + +# Create a symbolic link for Tomcat +ln -sf /etc/guacamole/guacamole.war /var/lib/${TOMCAT_VERSION}/webapps/ + +# Move MySQL connector/j files +echo -e "${GREY}Moving mysql-connector-j-${MYSQLJCON}.jar (/etc/guacamole/lib/mysql-connector-java.jar)..." +mv -f mysql-connector-j-${MYSQLJCON}/mysql-connector-j-${MYSQLJCON}.jar /etc/guacamole/lib/mysql-connector-java.jar +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Configure guacamole.properties file +rm -f /etc/guacamole/guacamole.properties +touch /etc/guacamole/guacamole.properties +echo "mysql-hostname: ${MYSQL_HOST}" >>/etc/guacamole/guacamole.properties +echo "mysql-port: ${MYSQL_PORT}" >>/etc/guacamole/guacamole.properties +echo "mysql-database: ${GUAC_DB}" >>/etc/guacamole/guacamole.properties +echo "mysql-username: ${GUAC_USER}" >>/etc/guacamole/guacamole.properties +echo "mysql-password: ${GUAC_PWD}" >>/etc/guacamole/guacamole.properties + +# Move TOTP files +if [ "${INSTALL_TOTP}" = true ]; then + echo -e "${GREY}Moving guacamole-auth-totp-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..." + mv -f guacamole-auth-totp-${GUAC_VERSION}/guacamole-auth-totp-${GUAC_VERSION}.jar /etc/guacamole/extensions/ + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 + else + echo -e "${LGREEN}OK${GREY}" + echo + fi +fi + +# Move Duo files +if [ "${INSTALL_DUO}" = true ]; then + echo -e "${GREY}Moving guacamole-auth-duo-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..." + mv -f guacamole-auth-duo-${GUAC_VERSION}/guacamole-auth-duo-${GUAC_VERSION}.jar /etc/guacamole/extensions/ + echo "#duo-api-hostname: " >>/etc/guacamole/guacamole.properties + echo "#duo-integration-key: " >>/etc/guacamole/guacamole.properties + echo "#duo-secret-key: " >>/etc/guacamole/guacamole.properties + echo "#duo-application-key: " >>/etc/guacamole/guacamole.properties + echo -e "Duo auth is installed, it will need to be configured via guacamole.properties" + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 + else + echo -e "${LGREEN}OK${GREY}" + echo + fi +fi + +# Move LDAP files +if [ "${INSTALL_LDAP}" = true ]; then + echo -e "${GREY}Moving guacamole-auth-ldap-${GUAC_VERSION}.jar (/etc/guacamole/extensions/)..." + mv -f guacamole-auth-ldap-${GUAC_VERSION}/guacamole-auth-ldap-${GUAC_VERSION}.jar /etc/guacamole/extensions/ + echo "#If you have issues with LDAP, check the formatting is exactly as below or you will despair!" >>/etc/guacamole/guacamole.properties + echo "#Be extra careful with spaces at line ends or with windows line feeds." >>/etc/guacamole/guacamole.properties + echo "#ldap-hostname: dc1.yourdomain.com dc2.yourdomain.com" >>/etc/guacamole/guacamole.properties + echo "#ldap-port: 389" >>/etc/guacamole/guacamole.properties + echo "#ldap-username-attribute: sAMAccountName" >>/etc/guacamole/guacamole.properties + echo "#ldap-encryption-method: none" >>/etc/guacamole/guacamole.properties + echo "#ldap-search-bind-dn: ad-account@yourdomain.com" >>/etc/guacamole/guacamole.properties + echo "#ldap-search-bind-password: ad-account-password" >>/etc/guacamole/guacamole.properties + echo "#ldap-config-base-dn: dc=domain,dc=com" >>/etc/guacamole/guacamole.properties + echo "#ldap-user-base-dn: OU=SomeOU,DC=domain,DC=com" >>/etc/guacamole/guacamole.properties + echo "#ldap-user-search-filter:(objectClass=user)(!(objectCategory=computer))" >>/etc/guacamole/guacamole.properties + echo "#ldap-max-search-results:200" >>/etc/guacamole/guacamole.properties + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 + else + echo -e "${LGREEN}OK${GREY}" + echo + fi +fi + +# Apply branded interface, you may delete this file and restart guacd & tomcat for default branding +echo -e "${GREY}Applying branded Guacamole login page and favicons..." +# For details on how to brand Guacamole, see https://github.com/Zer0CoolX/guacamole-customize-loginscreen-extension +sudo mv branding.jar /etc/guacamole/extensions +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Restart Tomcat +echo -e "${GREY}Restarting Tomcat service & enable at boot..." +service ${TOMCAT_VERSION} restart +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" +fi +# Set Tomcat to start at boot +systemctl enable ${TOMCAT_VERSION} +echo + +# Set MySQL password +export MYSQL_PWD=${MYSQL_ROOT_PWD} + +# Restart MySQL service +if [ "${INSTALL_MYSQL}" = true ]; then + echo -e "${GREY}Restarting MySQL service & enable at boot..." + # Set MySQl to start at boot + systemctl enable mysql + service mysql restart + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed${GREY}" 1>&2 + exit 1 + else + echo -e "${LGREEN}OK${GREY}" + echo + fi +fi + +# Default locations of MySQL config files +for x in /etc/mysql/mariadb.conf.d/50-server.cnf \ + /etc/mysql/mysql.conf.d/mysqld.cnf \ + /etc/mysql/my.cnf; do + # Check the path exists + if [ -e "${x}" ]; then + # Does it have the necessary section? + if grep -q '^\[mysqld\]$' "${x}"; then + mysqlconfig="${x}" + break + fi + fi +done + +if [ -z "${mysqlconfig}" ]; then + echo -e "${GREY}Couldn't detect MySQL config file - you may need to manually enter timezone settings" +else + # Is there already a value? + if grep -q "^default_time_zone[[:space:]]?=" "${mysqlconfig}"; then + echo -e "MySQL database timezone already defined in ${mysqlconfig}" + else + timezone="$(cat /etc/timezone)" + if [ -z "${timezone}" ]; then + echo -e "Couldn't find system timezone, using UTC$" + timezone="UTC" + fi + echo -e "Setting MySQL database timezone as ${timezone}${GREY}" + # Fix for https://issues.apache.org/jira/browse/GUACAMOLE-760 + mysql_tzinfo_to_sql /usr/share/zoneinfo 2>/dev/null | mysql -u root -D mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT} + crudini --set ${mysqlconfig} mysqld default_time_zone "${timezone}" + # Restart to apply + service mysql restart + fi +fi +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Create ${GUAC_DB} and grant ${GUAC_USER} permissions to it +# SQL code +GUAC_USERHost="localhost" +if [[ "${MYSQL_HOST}" != "localhost" ]]; then + GUAC_USERHost="%" + echo -e "${YELLOW}MySQL Guacamole user is set to accept login from any host, please change this for security reasons if possible.${GREY}" +fi + +# Check for ${GUAC_DB} already being there +echo -e "${GREY}Checking MySQL for existing database (${GUAC_DB})" +SQLCODE=" +SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='${GUAC_DB}';" + +# Execute SQL code +MYSQL_RESULT=$(echo ${SQLCODE} | mysql -u root -D information_schema -h ${MYSQL_HOST} -P ${MYSQL_PORT}) +if [[ $MYSQL_RESULT != "" ]]; then + echo -e "${LRED}It appears there is already a MySQL database (${GUAC_DB}) on ${MYSQL_HOST}${GREY}" 1>&2 + echo -e "${LRED}Try: mysql -e 'DROP DATABASE ${GUAC_DB}'${GREY}" 1>&2 +#exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Check for ${GUAC_USER} already being there +echo -e "${GREY}Checking MySQL for existing user (${GUAC_USER})" +SQLCODE=" +SELECT COUNT(*) FROM mysql.user WHERE user = '${GUAC_USER}';" + +# Execute SQL code +MYSQL_RESULT=$(echo ${SQLCODE} | mysql -u root -D mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT} | grep '0') +if [[ $MYSQL_RESULT == "" ]]; then + echo -e "${LRED}It appears there is already a MySQL user (${GUAC_USER}) on ${MYSQL_HOST}${GREY}" 1>&2 + echo -e "${LRED}Try: mysql -e \"DROP USER '${GUAC_USER}'@'${GUAC_USERHost}'; FLUSH PRIVILEGES;\"${GREY}" 1>&2 +#exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Create database & user, then set permissions +SQLCODE=" +DROP DATABASE IF EXISTS ${GUAC_DB}; +CREATE DATABASE IF NOT EXISTS ${GUAC_DB}; +CREATE USER IF NOT EXISTS '${GUAC_USER}'@'${GUAC_USERHost}' IDENTIFIED BY \"${GUAC_PWD}\"; +GRANT SELECT,INSERT,UPDATE,DELETE ON ${GUAC_DB}.* TO '${GUAC_USER}'@'${GUAC_USERHost}'; +FLUSH PRIVILEGES;" + +# Execute SQL code +echo ${SQLCODE} | mysql -u root -D mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT} + +# Add Guacamole schema to newly created database +echo -e "${GREY}Adding database tables..." +cat guacamole-auth-jdbc-${GUAC_VERSION}/mysql/schema/*.sql | mysql -u root -D ${GUAC_DB} -h ${MYSQL_HOST} -P ${MYSQL_PORT} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Create guacd.conf. This is later changed to 127.0.0.1 during Nginx reverse proxy install. +echo -e "${GREY}Binding guacd to 0.0.0.0 port 4822..." +cat >/etc/guacamole/guacd.conf <<-"EOF" +[server] +bind_host = 0.0.0.0 +bind_port = 4822 +EOF +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Ensure guacd is started +echo -e "${GREY}Starting guacd service & enable at boot..." +systemctl enable guacd +service guacd stop 2>/dev/null +service guacd start +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Cleanup +echo -e "${GREY}Cleanup install files...${GREY}" +rm -rf guacamole-* +rm -rf mysql-connector-j-* +unset MYSQL_PWD +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Apply Secure MySQL installation settings +if [ "${SECURE_MYSQL}" = true ]; then + echo -e "${GREY}Applying mysql_secure_installation settings...${DGREY}" + MYSQLPW=${MYSQL_ROOT_PWD} + SECURE_MYSQL=$(expect -c " +set timeout 10 +spawn mysql_secure_installation +expect \"Enter current password for root (enter for none):\" +send \"$MYSQLPW\r\" +expect \"Switch to unix_socket authentication\" +send \"n\r\" +expect \"Change the root password?\" +send \"n\r\" +expect \"Remove anonymous users?\" +send \"y\r\" +expect \"Disallow root login remotely?\" +send \"y\r\" +expect \"Remove test database and access to it?\" +send \"y\r\" +expect \"Reload privilege tables now?\" +send \"y\r\" +expect eof +") + echo "$SECURE_MYSQL" + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 + else + echo -e "${LGREEN}OK${GREY}" + fi +fi + +# Done +echo -e ${NC} diff --git a/3-install-nginx.sh b/3-install-nginx.sh new file mode 100644 index 0000000..472a4b0 --- /dev/null +++ b/3-install-nginx.sh @@ -0,0 +1,127 @@ +#!/bin/bash +####################################################################################################################### +# Add Nginx reverse proxy fromt end to default Guacamole install +# For Ubuntu / Debian / Raspbian +# 3 of 4 +# David Harrop +# August 2023 +####################################################################################################################### + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +echo +echo +echo -e "${LGREEN}Installing Nginx...${DGREY}" +echo + +# Install Nginx +sudo apt-get install nginx -qq -y &>>${LOG_LOCATION} + +echo -e "${GREY}Configuring Nginx as a reverse proxy for Guacamole's Apache Tomcat front end...${DGREY}" +# Configure /etc/nginx/sites-available/(local dns site name) +cat <&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Symlink from sites-available to sites-enabled +ln -s /etc/nginx/sites-available/$PROXY_SITE /etc/nginx/sites-enabled/ + +# Make sure default Nginx site is unlinked +unlink /etc/nginx/sites-enabled/default + +# Do mandatory Nginx tweaks for logging actual client IPs through a proxy IP of 127.0.0.1 - DO NOT CHANGE COMMAND FORMATING! +echo -e "${GREY}Configuring Apache Tomcat valve for pass through of client IPs to Guacamole logs...${GREY}" +sudo sed -i '/pattern="%h %l %u %t "%r" %s %b"/a \ \n ' /etc/$TOMCAT_VERSION/server.xml +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Allow large file transfers through Nginx +sudo sed -i '/client_max_body_size/d' /etc/nginx/nginx.conf # remove this line if it already exists to prevent duplicates +sudo sed -i "/Basic Settings/a \ client_max_body_size 100000000M;" /etc/nginx/nginx.conf # Add the larger file transfer size +echo -e "${GREY}Boosting Nginx's 'maximum body size' parameter to allow large file transfers...${GREY}" +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Bind guacd to localhost and force all Guacamole connections via reverse proxy +echo -e "${GREY}Binding guacd to 127.0.0.1 port 4822..." +cp /etc/guacamole/guacd.conf /etc/guacamole/guacd.conf.bak +cat >/etc/guacamole/guacd.conf <<-"EOF" +[server] +bind_host = 127.0.0.1 +bind_port = 4822 +EOF +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Update general ufw rules so force traffic via reverse proxy. Only Nginx and SSH will be available over the network. +echo -e "${GREY}Updating firewall rules to allow only SSH and tcp 80/443..." +sudo ufw default allow outgoing >/dev/null 2>&1 +sudo ufw default deny incoming >/dev/null 2>&1 +sudo ufw allow OpenSSH >/dev/null 2>&1 +sudo ufw allow 80/tcp >/dev/null 2>&1 +echo "y" | sudo ufw enable >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Reload everything +echo -e "${GREY}Restaring Guacamole & Ngnix..." +sudo systemctl restart $TOMCAT_VERSION +sudo systemctl restart guacd +sudo systemctl restart nginx +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" +fi + +# Done +echo -e ${NC} diff --git a/4a-install-ssl-self-signed-nginx.sh b/4a-install-ssl-self-signed-nginx.sh new file mode 100644 index 0000000..ff47212 --- /dev/null +++ b/4a-install-ssl-self-signed-nginx.sh @@ -0,0 +1,256 @@ +#!/bin/bash +####################################################################################################################### +# Add self signed SSL certificates to Guacamole with Nginx reverse proxy +# For Ubuntu / Debian / Rasbpian +# 4a of 4 +# David Harrop +# April 2023 +####################################################################################################################### + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +echo +echo +echo -e "${LGREEN}Setting up self signed SSL certificates for Nginx...${GREY}" +echo + +# Setup script cmd line arguments for proxy site and certificate days +SSLNAME=$1 +SSLDAYS=$2 + +####################################################################################################################### +# If you wish to add/regenerate self signed SSL to a pre-existing Nginx install, this script can be adapted to be run +# standalone. To run as standalone, simply un-comment this entire section and provide the desired variable +# values to complete the reconfiguration of Nginx. + +# Variable inputs +#TOMCAT_VERSION="tomcat9" # Not needed for general SSL install(if Guacamole not present, also comment the tomcat restart) +#DOWNLOAD_DIR=$(eval echo ~${SUDO_USER}) +#LOG_LOCATION="${DOWNLOAD_DIR}/ssl_install.log" +#TMP_DIR=/tmp +#GUAC_URL=http://localhost:8080/guacamole/ # substitute for whatever url that nginx is proxying +#CERT_COUNTRY="AU" # must be two letter code! +#CERT_STATE="Victoria" +#CERT_LOCATION="Melbourne" +#CERT_ORG="Itiligent" +#CERT_OU="I.T. dept" +#PROXY_SITE=$SSLNAME + +# To run manually or to regenerate SSL certificates, this script must be run in the current user environment [-E switch] +# Be aware that running this script just as sudo will save certs to sudo's home path with incorrect permissions, +# plus the custom certificate install instructions shown after running will be invalid. + +# e.g. sudo -E ./4a-install-ssl-self-signed-nginx.sh proxy-site-name 3650 + +####################################################################################################################### + +# Discover IPv4 interface +echo -e "${GREY}Discovering the default route interface and Proxy DNS name to bind with the new SSL certificate..." +DEFAULT_IP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +echo -e "${GREY}New self signed SSL certificate attributes are shown below...${DGREY}" +# Display the new SSL cert parameters. +cat <&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Place SSL Certificate within defined path +sudo cp $SSLNAME.key $DIR_SSL_KEY/$SSLNAME.key +sudo cp $SSLNAME.crt $DIR_SSL_CERT/$SSLNAME.crt + +# Create a PFX formatted key for easier import to Windows hosts and change permissions to enable copying elsewhere +echo -e "${GREY}Creating client certificates for Windows & Linux...${GREY}" +sudo openssl pkcs12 -export -out $SSLNAME.pfx -inkey $SSLNAME.key -in $SSLNAME.crt -password pass:1234 +sudo chmod 0774 $SSLNAME.pfx +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Backup the current Nginx config before update +echo -e "${GREY}Backing up previous Nginx proxy to $DOWNLOAD_DIR/$PROXY_SITE-nginx.bak" +cp /etc/nginx/sites-enabled/${PROXY_SITE} $DOWNLOAD_DIR/${PROXY_SITE}-nginx.bak +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Update Nginx config to accept the new certificates +echo -e "${GREY}Configuring Nginx proxy to use self signed SSL certificates and setting up automatic HTTP to HTTPS redirect...${DGREY}" +#cat > /etc/nginx/sites-available/$PROXY_SITE < /dev/null +cat <&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Update general ufw rules so force traffic via reverse proxy. Only Nginx and SSH will be available over the network. +echo -e "${GREY}Updating firewall rules to allow only SSH and tcp 80/443..." +sudo ufw default allow outgoing >/dev/null 2>&1 +sudo ufw default deny incoming >/dev/null 2>&1 +sudo ufw allow OpenSSH >/dev/null 2>&1 +sudo ufw allow 80/tcp >/dev/null 2>&1 +sudo ufw allow 443/tcp >/dev/null 2>&1 +echo "y" | sudo ufw enable >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Reload everything +echo -e "${GREY}Restaring Guacamole & Ngnix..." +sudo systemctl restart $TOMCAT_VERSION +sudo systemctl restart guacd +sudo systemctl restart nginx +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Hack to assist with displaying "$" symbols and " ' quotes in a (cut/pasteable) bash screen output format for Nginx configs +SHOWASTEXT1='$mypwd' +SHOWASTEXT2='"Cert:\LocalMachine\Root"' + +printf "${GREY}+------------------------------------------------------------------------------------------------------------- +${LGREEN}+ WINDOWS CLIENT SELF SIGNED SSL BROWSER CONFIG - SAVE THIS BEFORE CONTINUING!${GREY} ++ ++ 1. In ${DOWNLOAD_DIR} is a Windows version of the new certificate ${LYELLOW}$SSLNAME.pfx${GREY} ++ 2. Import this PFX file into your Windows client with the below Powershell commands (as Administrator): +\n" +echo -e "${SHOWASTEXT1} = ConvertTo-SecureString -String "1234" -Force -AsPlainText" +echo -e "Import-pfxCertificate -FilePath $SSLNAME.pfx -Password "${SHOWASTEXT1}" -CertStoreLocation "${SHOWASTEXT2}"" +printf "${GREY}+------------------------------------------------------------------------------------------------------------- +${LGREEN}+ LINUX CLIENT SELF SIGNED SSL BROWSER CONFIG - SAVE THIS BEFORE CONTINUING!${GREY} ++ ++ 1. In ${DOWNLOAD_DIR} is a new Linux native OpenSSL certificate ${LYELLOW}$SSLNAME.crt${GREY} ++ 2. Import the CRT file into your Linux client certificate store with the below command: +\n" +echo -e "(If certutil is not installed, run apt-get install libnss3-tools)" +echo -e "mkdir -p $HOME/.pki/nssdb && certutil -d $HOME/.pki/nssdb -N" +echo -e "certutil -d sql:$HOME/.pki/nssdb -A -t "CT,C,c" -n $SSLNAME -i $SSLNAME.crt" +printf "+-------------------------------------------------------------------------------------------------------------\n" +echo -e "${LYELLOW}The above SSL browser config instructions are saved in ${LGREEN}$LOG_LOCATION${GREY}" + +# Done +echo -e ${NC} diff --git a/4b-install-ssl-letsencrypt-nginx.sh b/4b-install-ssl-letsencrypt-nginx.sh new file mode 100644 index 0000000..e0013de --- /dev/null +++ b/4b-install-ssl-letsencrypt-nginx.sh @@ -0,0 +1,179 @@ +#!/bin/bash +####################################################################################################################### +# Add Let's Encrypt SSL Certificates to Guacamole with Nginx reverse proxy +# For Ubuntu / Debian / Raspbian +# 4b of 4 +# David Harrop +# April 2023 +####################################################################################################################### + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +echo +echo +echo -e "${LGREEN}Installing Let's Encrypt SSL configuration for Nginx...${GREY}" +echo + +####################################################################################################################### +# If you wish to add/regenerate self signed SSL to a pre-existing Nginx install, this script can be adapted to be run +# standalone. To run as standalone, simply un-comment this entire section and provide the desired variable +# values to complete the reconfiguration of Nginx. + +# Variable inputs +#TOMCAT_VERSION="tomcat9" # Not be needed for genreral SSL install SSL (i.e. where Guacamole not present) +#DOWNLOAD_DIR=$(eval echo ~${SUDO_USER}) +#LOG_LOCATION="${DOWNLOAD_DIR}/ssl_install.log" +#GUAC_URL=http://localhost:8080/guacamole/ # substitute for whatever url that nginx is proxying + +# Find the existing nginx site name +#echo -e "${GREY}Discovering exising proxy sites to configure with SSL...${GREY}" +#for file in "/etc/nginx/sites-enabled"/* +#do +#PROXY_SITE="${file##*/}" +#done +#if [ $? -ne 0 ]; then +# echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 +# exit 1 +# else +# echo -e "${LGREEN}OK${GREY}" +#fi +#echo +# Prompt for the FQDN of the new Let's encrypt certificate +#while true +#do +#echo -e "${LGREEN}" +#read -p "Enter the public FQDN for your proxy site: " LE_DNS_NAME +#echo +# [ "${LE_DNS_NAME}" != "" ] && break +#done + +# Prompt for the admin/webmaster email for Let's encrypt certificate notifications +#while true +#do +#echo -e "${LGREEN}" +#read -p "Enter the email address for Let's Encrypt notifications : " LE_EMAIL +#echo +# [ "${LE_EMAIL}" != "" ] && break +#done +#echo -e "${GREY}" + +####################################################################################################################### + +# Install nginx +apt-get update -qq &>>${LOG_LOCATION} +apt-get install nginx certbot python3-certbot-nginx -qq -y &>>${LOG_LOCATION} + +# Backup the current Nginx config +echo +echo -e "${GREY}Backing up previous Nginx proxy to $DOWNLOAD_DIR/$PROXY_SITE-nginx.bak" +cp /etc/nginx/sites-enabled/${PROXY_SITE} $DOWNLOAD_DIR/${PROXY_SITE}-nginx.bak +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Configure Nginx to accept the new certificates +echo -e "${GREY}Configuring Nginx proxy for Let's Encrypt SSL and setting up automatic HTTP redirect...${GREY}" +cat >/etc/nginx/sites-available/$PROXY_SITE <&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Update general ufw rules so force traffic via reverse proxy. Only Nginx and SSH will be available over the network. +echo -e "${GREY}Updating firewall rules to allow only SSH and tcp 80/443..." +sudo ufw default allow outgoing >/dev/null 2>&1 +sudo ufw default deny incoming >/dev/null 2>&1 +sudo ufw allow OpenSSH >/dev/null 2>&1 +sudo ufw allow 80/tcp >/dev/null 2>&1 +sudo ufw allow 443/tcp >/dev/null 2>&1 +echo "y" | sudo ufw enable >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Bounce Nginx to reload the new Nginx config so certbot config can continue +systemctl restart nginx + +# Run certbot to create and associate certificates with currenly public IP (must have tcp 80 and 443 open to work) +certbot --nginx -n -d $LE_DNS_NAME --email $LE_EMAIL --agree-tos --redirect --hsts +echo -e +echo -e "${GREY}Let's Encrypt successfully installed, but check for any errors above (DNS & firewall are the usual culprits).${GREY}" +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Select a random daily time to schedule a daily check for Let's Encrypt certificates due to expire in next 30 days. +# If are any due to expire within a 30 day window, Certbot will attempt to renew automatically renew. +echo -e "${GREY}Scheduling automatic certificate renewals for certificates with < 30 days till expiry.)${GREY}" +#Dump out the current crontab +crontab -l >cron_1 +# Remove any previosly added certbot renewal entries +sed -i '/# certbot renew/d' cron_1 +# Randomly choose a daily update schedule and append this to the cron schedule +HOUR=$(shuf -i 0-23 -n 1) +MINUTE=$(shuf -i 0-59 -n 1) +echo "${MINUTE} ${HOUR} * * * /usr/bin/certbot renew --quiet --pre-hook 'service nginx stop' --post-hook 'service nginx start'" >>cron_1 +# Overwrite old cron settings and cleanup +crontab cron_1 +rm cron_1 +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Reload everything once again +echo -e "${GREY}Restaring Guacamole & Ngnix..." +sudo systemctl restart $TOMCAT_VERSION +sudo systemctl restart guacd +sudo systemctl restart nginx +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" +fi + +# Done +echo -e ${NC} diff --git a/ACTIVE-DIRECTORY-HOW-TO.md b/ACTIVE-DIRECTORY-HOW-TO.md new file mode 100644 index 0000000..593797e --- /dev/null +++ b/ACTIVE-DIRECTORY-HOW-TO.md @@ -0,0 +1,70 @@ +# Integrating Guacamole with Active Directory + +## **1. Ensure two way LDAP traffic is available to the Guacamole application server** + +- If Guacamole is operating in a separate network to that of your Active Directory Servers, allow TCP 389 between all Guacamole application servers and all Active Directory Domain Controllers nominated in the config script settings below. + +## **2. Establish the required accounts to bind with Active Directory** + +- An account with only **Domain Users** rights is sufficient for Guacamole to read and bind with Active Directory. + + - a. Create a new Guacamole admin account in the Guacamole application e.g. `guacbind-ad` and assign an appropriate password. + - b. Create a new Active Directory domain account of EXACTLY THE SAME NAME as the new admin account name above, only this time assign a DIFFERENT password to that which was used above. + +## **3. Edit the provided configuration script to reflect your specific Active Directory environment** + + Below is the EXACT format to follow in editing the `$USER_HOME_DIR/guac-setup/add-ldap-auth-guacamole.sh` script. Be careful not to introduce new lines, spaces at ends of lines or carriage returns as anything outside of this format will cause the extension to fail. You have been warned! + +``` +ldap-hostname: dc1.yourdomain.com dc2.yourdomain.com dc3.yourdomain.com +ldap-port: 389 +ldap-username-attribute: sAMAccountName +ldap-encryption-method: none +ldap-search-bind-dn: guacbind-ad@yourdomain.com +ldap-search-bind-password: guacbind-ad-password +ldap-config-base-dn: dc=yourdomain,dc=com +ldap-user-base-dn: OU=SomeOU,DC=yourdomain,DC=com +ldap-user-search-filter:(objectClass=user)(!(objectCategory=computer)) +ldap-max-search-results:200 +mysql-auto-create-accounts: true +``` + + **Edit only the following values from the above example to suit your environment, then save the script** +``` +ldap-hostname +ldap-search-bind-dn +ldap-search-bind-password +ldap-config-base-dn +ldap-user-base-dn +mysql-auto-create-accounts: true +ldap-max-search-results:200 +``` + - **_Important note on `ldap-user-base-dn:`_** _This value sets a position in the directory as a relative root to search within. All Guacamole users to be authenticated by Active Directory must be placed in a lower position within the directory tree to this value. This line can be added multiple times to more efficiently search across multiple branches of a directory tree._ + + - **_Important note on `ldap-max-search-results:`_** _Yes, there is no space before the :200 value. In larger environments managing the directory efficiently requires we don't query every object in the tree for every user lookup. You may need to adjust this number depending on the number of objects in you tree._ + + - **_Important note on `mysql-auto-create-accounts:`_** _This line is optional and can be deleted. This line ensures that all Active Directory user accounts will have a matching user account created in the Guacamole db at first logon. Local Guacamole accounts are NOT necessarily needed for access to Guacamole connections - these are only necessary when deploying MFA or you want to assign other settings specific to individual users. Domain users can be provisioned access to connections without creating local users in the Guacamole db. For many use cases, manually creating a small number of Guacamole user accounts to their matching domain accounts may be more preferable than all users inheriting access to establish a local account in the Guacamole db. See below for manual account setup._ + +## **4. Run the configuration script** + +`sudo $USER_HOME_DIR/guac-setup/add-ldap-auth-guacamole.sh` + +## **5. Logging on to Guacamole with the new guacbind-ad account** + +- When logging in to Guacamole as the new Active Directory account created above, that user is both a Guacamole admin and a Domain User. If all is working correctly, all the users located below the directory position in **ldap-user-base-dn** will be listed under **Settings | Users** of the Guacamole management console. + +## **6. Manually creating and configuring new Guacamole users for Active Directory authentication** + +- If not using the **mysql-auto-create-accounts** directive, manually re-create the exact user names in Guacamole as those in the directory you wish to give Guacamole access. DO NOT configure Guacamole password for users that will be authenticating with Active directory. Guacamole local user accounts without a password are first given an MFA challenge (if MFA is configured for that user) and then will be brokered to Active Directory. Guacamole local user accounts with passwords will refer to the local db for authentication. This design allows for a matrix of local, domain, MFA & non MFA access to be deployed. + +## **7. Logging on using either the local vs the domain guacbind-ad account** + +- As described above, logging on with the Guacamole password will authenticate via the local Guacamole admin account version, conversely if the domain account password is given, the domain account is used to authenticate to Guacamole. It may sometimes be necessary to log on with the local account to manage some admin functions, but doing so will no be able to see the user list from Active Directory. When logged on with the domain version of the `guacbind-ad` account, domain user permissions to Guacamole can be managed. + +## **8. Creating a Single Sign On user experience for remote desktop access** + +- Create a Global Security domain group (e.g. Guac_Users) and populate it with selected users accordingly. Now add this new security group to the built-in “Remote Desktop Users” domain group. +- Next, for each connection profile you wish to create the SSO behaviour, _parameter_ _tokens_ must be used in place of hard coded values as follows... + - Add the parameter token `${GUAC_USERNAME}` to the Username field for each connection profile + - Add the parameter token `${GUAC_PASSWORD}` to the Password field for each connection profile +- Guacamole will now dynamically pass the domain username and password used to authenticate with Guacamole directly through to the remote desktop session. If that user has directory rights to access that system via remote desktop, they will be automatically authenticated to the remote session without needing a desktop authentication prompt. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fe6b903 --- /dev/null +++ b/LICENSE @@ -0,0 +1,662 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..1dd1b58 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +# Guacamole 1.5.2 Virtual Desktop & Jump Server Appliance + +A menu based build & install script for Guacamole 1.5.2 with support for SSL reverse proxy, AD integration, Multi-Factor Authentication and further security hardening. + +## Automatic Build, Install & Config Script + +To install Guacamole, copy and paste the following command into your terminal: + +``` +wget https://raw.githubusercontent.com/itiligent/Guacamole-Setup/main/1-setup.sh && chmod +x 1-setup.sh && ./1-setup.sh +``` + +## Prerequisites + +- Ubuntu 18.04 - 22.x / Debian 10 & 11 / Raspbian Buster or Bullseye + ### PLEASE NOTE: LASTEST DEBIAN 12 HAS SEVERAL PENDING ISSUES - SEE ISSUE #8 +- Minimum 8GB RAM and 40GB HDD +- Public or private DNS entries that match the default physical interface IP address (required for self SSL) +- Incoming access on TCP ports 22, 80, and 443 + +## Setup Menu Flow + +### 1. Setup MYSQL + +- Install Guacamole with a new local MYSQL, or use an existing/remote MySQL instance. +- Sub option: Add MySQL `mysql_secure_installation` settings to the local or remote MySQL instance + +### 2. Select Authentication Extension + +- Choose an authentication extension [DUO, TOTP, LDAP or None] - *Simultaneous TOTP and DUO not possible, but LDAP with TOTP is ok.* + +### 3. Choose Guacamole Front End + +- Install Nginx Reverse Proxy?: y/n ( n = default Guacamole frontend `http://hostname:8080/guacamole`) +- Install Nginx with no SSL?: y/n ( y = `http://hostname.local`) +- Install Nginx with self-signed SSL certificates?: y/n ( y = `https://hostname.local`) - *Configures Nginx with a new self signed TLS certificate and generates corresponding Windows/Linux browser certificates in the `$DOWNLOAD_DIR/guac-setup` directory* +- Install Nginx with Let's Encrypt certificates?: y/n ( y =`https://public.site.com`) - *Configures Nginx with a new LetsEncrypt certificate and sets up auto renewals.)* + +### Optional post install hardening + +The installer downloads additional scripts for: +- Adding a fail2ban lockdown policy for Guacamole +- Encrypting internal traffic between the Guacamole client and Guacd daemon with SSL +- Integrating with Active Directory (See ACTIVE-DIRECTORY-HOW-TO.md) +- Adding email alerts via Microsoft365 (SMTP auth) + +## Installation Notes + +To create a custom or unattended setup, follow these steps: +1. From a terminal session, change to your home directory then paste and run above wget link. +2. Exit `1-setup.sh` script at the first prompt. (At this point, only the scripts are downloaded). +3. Edit the "Silent setup options" section of `1-setup.sh`. + - *Note that script variables with an actual setting (e.g., `VARIABLE="value"`) will NOT prompt during the interactive setup. This means that with the right combination of variable inputs, it is possible to mass deploy a full Guacamole appliance with Nginx & SSL with zero touch.* +4. After setting custom values in `1-setup.sh`, you must run the modified script saved locally with `./1-setup.sh` Beware: If you run the wget link again you will overwrite all your changes! + - *For adaptations made to any other downloaded script, you must comment out the relevant wget lines in the "Download GitHub Setup" section at the top of `1-setup.sh` to prevent these from being re-downloaded and overwritten as well.* + - *There should be no need to customise any scripts other than `1-setup.sh` as all install options are managed in the first parent script.* + - *Be aware that all optional (manually run) `add-x.sh` scripts are dynamically updated during the installation with the exact variables you selected at install. Editing anything other than `1-setup.sh` may break this functionality, so make changes only if you understand the impacts.* + +### Glossary of items downloaded by the setup script + +The setup command mentioned above downloads the following items into the `$DOWNLOAD_DIR/guac-setup` directory: + +- `1-setup.sh`: The parent install script itself +- `2-install-guacamole.sh`: Guacamole installation script (inspired by [MysticRyuujin/guac-install](https://github.com/MysticRyuujin/guac-install)) +- `3-install-nginx.sh`: Installs Nginx & auto-configures a front-end reverse proxy for Guacamole (optional) +- `4a-install-ssl-self-signed-nginx.sh`: Configures self-signed SSL certificates for Nginx proxy (optional) +- `4b-install-ssl-letsencrypt-nginx.sh`: Installs & configures Let's Encrypt with Guacamole & Nginx proxy (optional) +- `add-auth-duo.sh`: Adds the Duo MFA extensions if not selected during install (optional) +- `add-auth-ldap.sh`: Adds the Active Directory extension and setup template if not selected at install (optional) +- `add-auth-totp.sh`: Adds the TOTP MFA extension if not selected at install (optional) +- `add-ssl-guac-gaucd.sh`: A hardening script to TLS wrap traffic between the guacd server & the Guacamole client application (optional) +- `add-fail2ban.sh`: Adds & configures a fail2ban white list to secure Guacamole against brute force attacks +- `add-smtp-relay-o365.sh`: Sets up a TLS/SMTP auth relay with O365 for monitoring & alerts (BYO app password) +- `backup-guacamole.sh`: A simple Guacamole backup script +- `branding.jar`: An example customised Guacamole login screen to brand Guacamole to your own requirements (or delete to keep the default interface.) This is a modified version of https://github.com/Zer0CoolX/guacamole-customize-loginscreen-extension but with with additional support for browser favicons. + +Special acknowledgement to [MysticRyuujin](https://github.com/MysticRyuujin/guac-install) whose repository provided many helpful ideas for assembling this project. diff --git a/add-auth-duo.sh b/add-auth-duo.sh new file mode 100644 index 0000000..96f4d8c --- /dev/null +++ b/add-auth-duo.sh @@ -0,0 +1,58 @@ +#!/bin/bash +####################################################################################################################### +# Add Duo (MFA) support to Guacamole +# For Ubuntu / Debian / Raspbian +# David Harrop +# April 2023 +####################################################################################################################### + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +clear + +if ! [ $(id -u) = 0 ]; then + echo + echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2 + exit 1 +fi +TOMCAT_VERSION=$(ls /etc/ | grep tomcat) +GUAC_VERSION=$(grep -oP 'Guacamole.API_VERSION = "\K[0-9\.]+' /var/lib/${TOMCAT_VERSION}/webapps/guacamole/guacamole-common-js/modules/Version.js) +GUAC_SOURCE_LINK="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUAC_VERSION}" + +echo +wget -q --show-progress -O guacamole-auth-duo-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${GUAC_VERSION}.tar.gz +tar -xzf guacamole-auth-duo-${GUAC_VERSION}.tar.gz +echo +mv -f guacamole-auth-duo-${GUAC_VERSION}/guacamole-auth-duo-${GUAC_VERSION}.jar /etc/guacamole/extensions/ +chmod 664 /etc/guacamole/extensions/guacamole-auth-duo-${GUAC_VERSION}.jar +echo "duo-integration-key: " >>/etc/guacamole/guacamole.properties +echo "duo-secret-key: " >>/etc/guacamole/guacamole.properties +echo "duo-api-hostname: " >>/etc/guacamole/guacamole.properties +echo "duo-application-key: " >>/etc/guacamole/guacamole.properties + +systemctl restart ${TOMCAT_VERSION} +sudo systemctl restart guacd + +echo -e "${LYELLOW}You must now set up your online Duo account with a new 'Web SDK' application." +echo +echo "Next you must copy the API settings from your Duo account into /etc/guacamole/guacamole.properties in the EXACT below format." +echo -e "Be VERY careful to avoid extra trailing spaces or other line feed characters when pasting!${GREY}" +echo +echo "duo-integration-key: ??????????" +echo "duo-api-hostname: ??????????" +echo "duo-secret-key: ??????????" +echo "duo-application-key: (this is locally created - run 'pwgen 40 1' to manually generate this 40 char random value)" +echo +echo "Once this change is complete, restart Guacamole with sudo systemctl restart tomcat9" + +rm -rf guacamole-* + +echo +echo -e ${NC} diff --git a/add-auth-ldap.sh b/add-auth-ldap.sh new file mode 100644 index 0000000..58dd3c0 --- /dev/null +++ b/add-auth-ldap.sh @@ -0,0 +1,76 @@ +#!/bin/bash +####################################################################################################################### +# Add Active Directory integration with Guacamole +# For Ubuntu / Debian / Raspbian +# David Harrop +# April 2023 +####################################################################################################################### + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +clear + +# Check if user is root or sudo + +if ! [ $(id -u) = 0 ]; then + echo + echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2 + exit 1 +fi + +TOMCAT_VERSION=$(ls /etc/ | grep tomcat) +GUAC_VERSION=$(grep -oP 'Guacamole.API_VERSION = "\K[0-9\.]+' /var/lib/${TOMCAT_VERSION}/webapps/guacamole/guacamole-common-js/modules/Version.js) +GUAC_SOURCE_LINK="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUAC_VERSION}" + +echo +echo -e "${LYELLOW}Have you updated this script to reflect your Active Directory settings?${NC}" + +read -p "Do you want to proceed? (yes/no) " yn +echo +case $yn in +y) echo Beginning LDAP auth config... ;; +n) + echo exiting... + exit + ;; +*) + echo invalid response + exit 1 + ;; +esac + +echo +wget -q --show-progress -O guacamole-auth-ldap-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${GUAC_VERSION}.tar.gz +tar -xzf guacamole-auth-ldap-${GUAC_VERSION}.tar.gz +echo +echo Adding the below config to /etc/guacamole/guacamole.properties +cat <&2 + exit 1 +fi + +TOMCAT_VERSION=$(ls /etc/ | grep tomcat) +GUAC_VERSION=$(grep -oP 'Guacamole.API_VERSION = "\K[0-9\.]+' /var/lib/${TOMCAT_VERSION}/webapps/guacamole/guacamole-common-js/modules/Version.js) +GUAC_SOURCE_LINK="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUAC_VERSION}" + +echo +wget -q --show-progress -O guacamole-auth-totp-${GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${GUAC_VERSION}.tar.gz +tar -xzf guacamole-auth-totp-${GUAC_VERSION}.tar.gz +mv -f guacamole-auth-totp-${GUAC_VERSION}/guacamole-auth-totp-${GUAC_VERSION}.jar /etc/guacamole/extensions/ +chmod 664 /etc/guacamole/extensions/guacamole-auth-totp-${GUAC_VERSION}.jar +systemctl restart ${TOMCAT_VERSION} +systemctl restart guacd + +rm -rf guacamole-* + +echo +echo "Done!" +echo -e ${NC} diff --git a/add-fail2ban.sh b/add-fail2ban.sh new file mode 100644 index 0000000..90c52b1 --- /dev/null +++ b/add-fail2ban.sh @@ -0,0 +1,261 @@ +#!/bin/bash +####################################################################################################################### +# Add fail2ban restrictions to Guacamole +# For Ubuntu / Debian / Raspbian +# David Harrop +# April 2023 +####################################################################################################################### + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +clear + +if ! [ $(id -u) = 0 ]; then + echo + echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2 + exit 1 +fi + +# Initialise variables +FAIL2BAN_BASE="" +FAIL2BAN_GUAC="" +FAIL2BAN_NGINX="" +FAIL2BAN_SSH="" +TOMCAT_VERSION=$(ls /etc/ | grep tomcat) + +#Clean up from any previous runs +rm -f /tmp/fail2ban.conf +rm -f /tmp/ip_list.txt +rm -f /tmp/netaddr.txt +rm -f /tmp/fail2ban.update + +####################################################################################################################### +# Start setup prompts ################################################################################################# +####################################################################################################################### + +# Prompt to install fail2ban base app, default of yes +if [[ -z ${FAIL2BAN_BASE} ]]; then + echo + echo -e -n "${LGREEN}Install Fail2ban? [default y]: ${GREY}" + read PROMPT + if [[ ${PROMPT} =~ ^[Nn]$ ]]; then + FAIL2BAN_BASE=false + else + FAIL2BAN_BASE=true + fi +fi + +# Prompt to install Guacamole fail2ban config defaults, default of no +if [[ -z ${FAIL2BAN_GUAC} ]] && [[ "${FAIL2BAN_BASE}" = true ]]; then + echo -e -n "${GREY}POLICY: Apply Guacamole fail2ban security policy? (y/n) [default n]:${GREY}" + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + FAIL2BAN_GUAC=true + else + FAIL2BAN_GUAC=false + fi +fi + +# Prompt to install Nginx fail2ban config defaults , default of no +if [[ -z ${FAIL2BAN_NGINX} ]] && [[ "${FAIL2BAN_BASE}" = true ]]; then + echo -e -n "${GREY}POLICY: Apply Nginx fail2ban security policy? (y/n) [default n]:${GREY}" + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + FAIL2BAN_NGINX=true + else + FAIL2BAN_NGINX=false + fi +fi + +# Prompt to install SSH fail2ban config defaults , default of no +if [[ -z ${FAIL2BAN_SSH} ]] && [[ "${FAIL2BAN_BASE}" = true ]]; then + echo -e -n "${GREY}POLICY: Apply SSH fail2ban security policy? (y/n) [default n]:${GREY}" + read PROMPT + if [[ ${PROMPT} =~ ^[Yy]$ ]]; then + FAIL2BAN_SSH=true + else + FAIL2BAN_SSH=false + fi +fi + +####################################################################################################################### +# Fail2ban base setup ################################################################################################# +####################################################################################################################### + +# Install base fail2ban base application (no policy defined yet) +if [ "${FAIL2BAN_BASE}" = true ]; then + + #Update and install fail2ban (and john for management of config file updates) + sudo apt-get update -qq >/dev/null 2>&1 + sudo apt-get install fail2ban john -qq -y >/dev/null 2>&1 + + # Create the basic jail.local template + cat >/tmp/fail2ban.conf </tmp/ip_list.txt + + # Loop the list of discovered ips and extract the subnet ID addresses for each interface + FILE=/tmp/ip_list.txt + LINES=$(cat $FILE) + for LINE in $LINES; do + + tonum() { + if [[ $LINE =~ ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+) ]]; then + addr=$(((${BASH_REMATCH[1]} << 24) + (${BASH_REMATCH[2]} << 16) + (${BASH_REMATCH[3]} << 8) + ${BASH_REMATCH[4]})) + eval "$2=\$addr" + fi + } + toaddr() { + b1=$((($1 & 0xFF000000) >> 24)) + b2=$((($1 & 0xFF0000) >> 16)) + b3=$((($1 & 0xFF00) >> 8)) + b4=$(($1 & 0xFF)) + eval "$2=\$b1.\$b2.\$b3.\$b4" + } + + if [[ $LINE =~ ^([0-9\.]+)/([0-9]+)$ ]]; then + # CIDR notation + IPADDR=${BASH_REMATCH[1]} + NETMASKLEN=${BASH_REMATCH[2]} + PREFIX=$NETMASKLEN + zeros=$((32 - NETMASKLEN)) + NETMASKNUM=0 + for ((i = 0; i < $zeros; i++)); do + NETMASKNUM=$(((NETMASKNUM << 1) ^ 1)) + done + NETMASKNUM=$((NETMASKNUM ^ 0xFFFFFFFF)) + toaddr $NETMASKNUM NETMASK + else + IPADDR=${1:-192.168.1.1} + NETMASK=${2:-255.255.255.0} + fi + + tonum $IPADDR IPADDRNUM + tonum $NETMASK NETMASKNUM + + # The logic to calculate network and broadcast + INVNETMASKNUM=$((0xFFFFFFFF ^ NETMASKNUM)) + NETWORKNUM=$((IPADDRNUM & NETMASKNUM)) + BROADCASTNUM=$((INVNETMASKNUM | NETWORKNUM)) + + toaddr $NETWORKNUM NETWORK + toaddr $BROADCASTNUM BROADCAST + + # Reverse engineer the subnet ID from the calcualted IP address and subnet prefix + IFS=. read -r i1 i2 i3 i4 <<<"$IPADDR" + IFS=. read -r m1 m2 m3 m4 <<<"$NETMASK" + + # Lay out the subnet ID address as a variable + printf -v NETADDR "%d.%d.%d.%d" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))" + + #Dump out the calcualted subnet IDs to a file + echo $NETADDR"/"$NETMASKLEN | tr '\n' ' ' | cat >>/tmp/netaddr.txt + + done + +fi + +if [ "${FAIL2BAN_BASE}" = true ]; then + # Now the above loop is done, append the single loopback address to all the discovered the subnet IDs in a single line + sed -i 's/^/127.0.0.1\/24 /' /tmp/netaddr.txt + + # Finally assemble the entire syntaxt of the ignoreip whitelist for insertion into the base fail2ban config + SED_IGNORE=$(echo "ignoreip = ") + SED_NETADDR=$(cat /tmp/netaddr.txt) + sed -i "s|ignoreip \=|${SED_IGNORE}${SED_NETADDR}|g" /tmp/fail2ban.conf + + # Move the new base fail2ban config to the jail.local file + touch /etc/fail2ban/jail.local + + # Apply thhe base config, keeping any pre-existing settings + sudo bash -c 'cat /tmp/fail2ban.conf /etc/fail2ban/jail.local | unique /tmp/fail2ban.update ; cat /tmp/fail2ban.update > /etc/fail2ban/jail.local' + + # Clean up + rm -f /tmp/fail2ban.conf + rm -f /tmp/ip_list.txt + rm -f /tmp/netaddr.txt + rm -f /tmp/fail2ban.update + + # bounce the service to relaod the new config + sudo systemctl restart fail2ban + + # Done + echo + echo -e "${LGREEN}Fail2ban installed...${GREY}" + echo + +else + echo -e "${LGREEN}Fail2ban setup cancelled.${GREY}" + +fi + +####################################################################################################################### +# Fail2ban optional setup items ####################################################################################### +####################################################################################################################### + +# Create the Guacamole jail.local policy template +cat >/tmp/fail2ban.conf < /etc/fail2ban/jail.local' + +# Backup the defualt Fail2ban Guacamole filter +cp /etc/fail2ban/filter.d/guacamole.conf /etc/fail2ban/filter.d/guacamole.conf.bak + +# Remove the default log search regex +sudo bash -c 'sed -e "/Authentication attempt from/ s/^#*/#/" -i /etc/fail2ban/filter.d/guacamole.conf' + +# Create a new log search regex specific for tomcat logs (as a variable due to complexity of characters for sed syntax) +REGEX='failregex = ^.*WARN o\.a\.g\.r\.auth\.AuthenticationService - Authentication attempt from for user "[^"]*" failed\.$' +#Insert the new regex +sed -i -e "/Authentication attempt from/a ${REGEX}" /etc/fail2ban/filter.d/guacamole.conf + +# Bounce the service to relaod the new config +sudo systemctl restart fail2ban + +# Clean up +rm -f /tmp/fail2ban.conf +rm -f /tmp/ip_list.txt +rm -f /tmp/netaddr.txt +rm -f /tmp/fail2ban.update + +# Done +echo -e "${LGREEN}Guacamole security policy applied${GREY}\n-${SED_NETADDR}are whitelisted from all IP bans.\n- To alter this whitelist, edit /etc/fail2ban/jail.local & sudo systemctl restart fail2ban" +echo + +############## Start Fail2ban NGINX security policy option ############### +if [ "${FAIL2BAN_NGINX}" = true ]; then + echo -e "${LGREEN}Nginx Fail2ban policy not implemented yet.${GREY}" + echo +fi + +############### Start Fail2ban SSH security policy option ################ +if [ "${FAIL2BAN_SSH}" = true ]; then + echo -e "${LGREEN}SSH Fail2ban policy not implemented yet..${GREY}" + echo +fi + +#Done +echo -e ${NC} diff --git a/add-smtp-relay-o365.sh b/add-smtp-relay-o365.sh new file mode 100644 index 0000000..171f7d6 --- /dev/null +++ b/add-smtp-relay-o365.sh @@ -0,0 +1,123 @@ +#!/bin/bash +####################################################################################################################### +# SMTP relay with Office 365 Setup +# For Ubuntu / Debian / Raspbian +# David Harrop +# April 2023 +####################################################################################################################### + +# Prerequisites: +# An office 365 account with a mailbox (NON ADMIN!!) +# An app password created for the above office 365 user at https://mysignins.microsoft.com/security-info +# SMTP Auth enabled for that user under "manage mail apps in the Office365 admin centre + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +clear + +SENDER=$SUDO_USER +SERVER=$(uname -n) +DOMAIN_SEARCH_SUFFIX=$(grep search /etc/resolv.conf | grep -v "#" | sed 's/'search[[:space:]]'//') + +if ! [ $(id -u) = 0 ]; then + echo + echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2 + exit 1 +fi + +echo +echo -e "${LYELLOW}SMTP relay for Office365 setup...${LGREEN}" + +# Install Posfix +echo +echo -e "${GREY}Installing Postfix with non-interactive defaults..." +sudo apt update -qq >/dev/null 2>&1 +DEBIAN_FRONTEND="noninteractive" apt-get install postfix mailutils -qq -y >/dev/null 2>&1 +if [ $? -ne 0 ]; then + echo -e "${LRED}Postfix install failed. ${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" +fi + +# Get the Office365 smtp authentication credentials +echo +echo -e "${LYELLOW}An Office365 account email account is needed for SMTP relay authentication...${LGREEN}" +echo +read -p "Enter O365 SMTP auth enabled email : " SMTP_EMAIL +read -s -p "Enter the SMTP auth account 'app password': " APP_PWD +echo +echo + +# Remove some default Postifx config items that conflict with new entries +sudo sed -i '/relayhost/d' /etc/postfix/main.cf +sudo sed -i '/smtp_tls_security_level=may/d' /etc/postfix/main.cf + +# For simple relay outbound only, limit Postfix to just loopback and IPv4 +sed -i 's/inet_interfaces = all/inet_interfaces = loopback-only/g' /etc/postfix/main.cf +sed -i "s/inet_protocols = all/inet_protocols = ipv4/g" /etc/postfix/main.cf + +echo -e "${GREY}Configuring Postfix for O365 SMTP relay and TLS auth..." +# Add the new Office365 SMTP auth with TLS settings +cat </dev/null 2>&1 +relayhost = [smtp.office365.com]:587 +smtp_use_tls = yes +smtp_always_send_ehlo = yes +smtp_sasl_auth_enable = yes +smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd +smtp_sasl_security_options = noanonymous +smtp_sasl_tls_security_options = noanonymous +smtp_tls_security_level = encrypt +smtp_generic_maps = hash:/etc/postfix/generic +smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt +EOF +if [ $? -ne 0 ]; then + echo -e "${LRED}Postfix restart failed. ${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Setup the password file and postmap +sudo touch /etc/postfix/sasl_passwd +cat </dev/null 2>&1 +[smtp.office365.com]:587 ${SMTP_EMAIL}:${APP_PWD} +EOF +sudo chown root:root /etc/postfix/sasl_passwd +sudo chmod 0600 /etc/postfix/sasl_passwd +sudo postmap /etc/postfix/sasl_passwd + +# Setup the generic map file +sudo touch /etc/postfix/generic +cat </dev/null 2>&1 +root@${SERVER} ${SMTP_EMAIL} +${SENDER}@${SERVER} ${SMTP_EMAIL} +@${DOMAIN_SEARCH_SUFFIX} ${SMTP_EMAIL} +EOF +sudo chown root:root /etc/postfix/generic +sudo chmod 0600 /etc/postfix/generic +sudo postmap /etc/postfix/generic + +# Restart and test +echo -e "${GREY}Restarting Postfix..." +sudo service postfix restart +if [ $? -ne 0 ]; then + echo -e "${LRED}Postfix restart failed. ${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" +fi + +echo +read -p "Enter an email address to test that email relay is working : " TEST_EMAIL +echo "This is a test email" | mail -s "SMTP Auth Relay Is Working is working" ${TEST_EMAIL} -a "FROM:${SMTP_EMAIL}" +echo -e "${LGREEN}Test message sent.." +echo -e ${NC} diff --git a/add-ssl-guac-gaucd.sh b/add-ssl-guac-gaucd.sh new file mode 100644 index 0000000..f9311e2 --- /dev/null +++ b/add-ssl-guac-gaucd.sh @@ -0,0 +1,93 @@ +#!/bin/bash +####################################################################################################################### +# Harden Guacd <-> Guac client traffic in SSL wrapper +# For Ubuntu / Debian / Raspbian +# David Harrop +# April 2023 +####################################################################################################################### + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +CERT_COUNTRY= +CERT_STATE= +CERT_LOCATION= +CERT_ORG= +CERT_OU= + +clear + +if ! [ $(id -u) = 0 ]; then + echo + echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2 + exit 1 +fi + +# Create the special directory for guacd ssl certfifacte and key. +sudo mkdir /etc/guacamole/ssl +echo +cat <${DB_BACKUP_DIR}${GUAC_DB}-${TODAY}.sql +SQLFILE=${DB_BACKUP_DIR}${GUAC_DB}-${TODAY}.sql +if [ $? -ne 0 ]; then + echo -e "${LRED}Backup failed.${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}Backup completed ok.${GREY}" + echo +fi +gzip -f ${SQLFILE} +# Error check and email alerts +if [ $? -ne 0 ]; then + echo -e "${LRED}Backup failed.${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}${GUAC_DB} backup was successfully copied to ${DB_BACKUP_DIR}" + #mailx -s "Guacamomle Database Backup Success" ${BACKUP_EMAIL} + echo "${GUAC_DB} backup was successfully copied to $DB_BACKUP_DIR" | mailx -s "Guacamole backup " ${BACKUP_EMAIL} +fi + +echo -e ${NC} diff --git a/branding.jar b/branding.jar new file mode 100644 index 0000000000000000000000000000000000000000..09861b02d5595d1700192ab871b9746b43ef2f4b GIT binary patch literal 24217 zcmagEb8u%()HV8xZQHhO+jcUsZQFJ-aWb)O+qRR5ZQXg^`&NBl-GA<>+Ix4O>ONh& zYjxMIvzDR^2q-k*zell-P5OTt|LZ^jxBwGpX9hJ@C;-SReTXIyLx`rU2MhoR^uH1R z;}rkRM*Y`;1mv28sTYX2zE%9|Q2_w}=>Ot>vu*6nE$!&+-AtXFEPt8O|9j=C&TTK6I|z zi$8|B?H8EHAXyVDm@j?%3)_|nUcbjAoa}D|Mf<37eGSH1mZBVVL~46e&ofD;qKJwT z4Mr?V!E$4rE~M-N0;Yz+ZYYAfNGgSS*AU*wzD)`bcrBl0IzBeJML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Wxpp*+RN~#rwzYuLLj*`9y4sY4qIvzSiu-oiodVWv2Mds`zI&b;dN@6^avm)v1u8u zi`|~J4CbuG9hJ}!N0o5da^zmj3&XgjLWiKmbPqkv!-^p_uHf@Zpn`lmjd1Q*GOLe@ zhsiarpO$)YG>drQ@`I}|LgqFZ!Sxq-YxGlshoj<%Qk{57M$>;c)?>E zl3qp>I`rE4PAP@@dG$bBM;L0{cD?+CRsNeS?D6AYk<&=8WMKz8eW1OizJr-H@E?3( z9Xen2l~=~_e`QbKHioMPS01s7{t7p}9>0jx|1ym+@Gm~IXg~4WHX;-eg=YKUzTI@N z072!dH8i9pU%g<`#b#NW+v`^FuX~~5XpnK51<#A~de^0il^tH~@$-#p0JQ^>(9}d{ zaCvEPi1(0x`~MS}jr}V9YoLG~3H|#18=wvKH$eN3KL8FP@R!;DgwK8rWdAjYUeElm z$A5-t!-M_0{u+@7!v=%1a|;5P&b`97|8@Lw{7;=fLDs+P;J@DcC)WCR4SGF~S7_*e z*7)bD{K<>{eN}K?@!9`NkA7X4U-anzXJP(iNB?eE^ZzFMoh1FcV;0rPIm-XySODzr zI{t|&_+3OE|9>6-CGt18;CGGun8NG-uJJb@{m+cu?-~!}|ElqCiM!v$JaKjf|67^= zS%N-Q4aYyMk*sJv1QA%C^m|5J!Ro9uW04gWsnKU(g0;~dChj#I$@^z13Jbam literal 0 HcmV?d00001 diff --git a/upgrade-guac.sh b/upgrade-guac.sh new file mode 100644 index 0000000..3a31f34 --- /dev/null +++ b/upgrade-guac.sh @@ -0,0 +1,347 @@ +#!/bin/bash +###################################################################################################################### +# Guacamole appliance upgrade script +# For Ubuntu / Debian / Raspbian +# David Harrop +# April 2023 +####################################################################################################################### + +####################################################################################################################### +# Initial enviromment setup ########################################################################################### +####################################################################################################################### + +clear + +# Prepare text output colours +GREY='\033[0;37m' +DGREY='\033[0;90m' +GREYB='\033[1;37m' +LRED='\033[0;91m' +LGREEN='\033[0;92m' +LYELLOW='\033[0;93m' +NC='\033[0m' #No Colour + +if ! [ $(id -u) = 0 ]; then + echo + echo -e "${LGREEN}Please run this script as sudo or root${NC}" 1>&2 + exit 1 +fi + +#Setup download and temp directory paths +USER_HOME_DIR=$(eval echo ~${SUDO_USER}) +DOWNLOAD_DIR=$USER_HOME_DIR/guac-setup/upgrade + +# Script branding header +echo +echo -e "${GREYB}Itiligent Virtual Desktop Appliance UPGRADE" +echo -e " ${LGREEN}Powered by Guacamole" +echo + +# Setup directory locations +mkdir -p $DOWNLOAD_DIR + +# Version of Guacamole to upgrade to +NEW_GUAC_VERSION="1.5.2" + +# Get the currently installed Tomcat version. +TOMCAT_VERSION=$(ls /etc/ | grep tomcat) + +# Get the currently installed Guacamole version +OLD_GUAC_VERSION=$(grep -oP 'Guacamole.API_VERSION = "\K[0-9\.]+' /var/lib/${TOMCAT_VERSION}/webapps/guacamole/guacamole-common-js/modules/Version.js) + +# Set preferred Apache CDN download link +GUAC_SOURCE_LINK="http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${NEW_GUAC_VERSION}" +# Set preferred Apache CDN download link + +# Install log Location +LOG_LOCATION="${DOWNLOAD_DIR}/guacamole_${NEW_GUAC_VERSION}_upgrade.log" + +# Non interactive silent setup options - add true/false or specific values +MYSQL_HOST="" # leave blank for localhost default, only specify for remote servers +MYSQL_PORT="" # If blank default is 3306 +GUAC_DB="" # If blank default is guacamole_db +GUAC_USER="" # if blank default is guacamole_user +GUAC_PWD="" # Should not be blank as this may break some aspects of install +MYSQL_ROOT_PWD="" # Should not be blank as this may break some aspects of install + +echo +# For convenience & sanity check, display status of preset script options at start of install +echo -e "${GREY}Enabled non-interactive presets listed below, blank entries will prompt. Ctrl+x to stop/edit" +echo -e "${DGREY}Current Guacamole version\t= ${GREY}${OLD_GUAC_VERSION}" +echo -e "${DGREY}Guacamole upgrade version\t= ${GREY}${NEW_GUAC_VERSION}" +echo -e "${DGREY}MySQL hostname/IP\t\t= ${GREY}${MYSQL_HOST}" +echo -e "${DGREY}MySQL port\t\t\t= ${GREY}${MYSQL_PORT}" +echo -e "${DGREY}Guacamole db name\t\t= ${GREY}${GUAC_DB}" +echo -e "${DGREY}Guacamole db user name\t\t= ${GREY}${GUAC_USER}" +echo -e "${DGREY}Guacamole user pwd\t\t= ${GREY}${GUAC_PWD}" +echo -e "${DGREY}MySQL root pwd\t\t\t= ${GREY}${MYSQL_ROOT_PWD}${GREY}" +echo + +####################################################################################################################### +# Prompt inputs ####################################################################################################### +####################################################################################################################### + +# Get MySQL Hostname or IP +if [ -z "${MYSQL_HOST}" ]; then + read -s -p "Enter MySQL server hostname or IP [localhost]: " MYSQL_HOST + echo +fi + +# Get MySQL Port +if [ -z "${MYSQL_PORT}" ]; then + read -s -p "Enter MySQL server port [3306]: " MYSQL_PORT + echo +fi + +# Get MySQL database name +if [ -z "${GUAC_DB}" ]; then + read -s -p "Enter Guacamole database name [guacamole_db]: " GUAC_DB + echo +fi + +# Get MySQL user name +if [ -z "${GUAC_USER}" ]; then + read -s -p "Enter Guacamole user name [guacamole_user]: " GUAC_USER + echo +fi + +# Get Guacamole User password, confirm correct password entry and prevent blank passwords +if [ -z "${GUAC_PWD}" ]; then + read -s -p "Enter MySQL guacamole_user password: " GUAC_PWD + echo +fi + +# Get MySQL root password +if [ -z "${MYSQL_ROOT_PWD}" ]; then + read -s -p "Enter MySQL root password: " MYSQL_ROOT_PWD + echo +fi + +# Set prompt input defaults if values not given + +# Checking if a mysql host given, if not set a default +if [ -z "${MYSQL_HOST}" ]; then + MYSQL_HOST="localhost" +fi + +# Checking if a mysql port given, if not set a default +if [ -z "${MYSQL_PORT}" ]; then + MYSQL_PORT="3306" +fi + +# Checking if a database name given, if not set a default +if [ -z "${GUAC_DB}" ]; then + GUAC_DB="guacamole_db" +fi + +# Checking if a mysql user given, if not set a default +if [ -z "${GUAC_USER}" ]; then + GUAC_USER="guacamole_user" +fi + +####################################################################################################################### +# Start upgrade actions ############################################################################################## +####################################################################################################################### + +sudo apt-get upgrade -qq -y + +# Stop tomcat and guacd +systemctl stop ${TOMCAT_VERSION} +systemctl stop guacd + +cd $DOWNLOAD_DIR + +echo +echo -e "${GREY}Beggining Guacamole ${OLD_GUAC_VERSION} to ${NEW_GUAC_VERSION} upgrade..." +wget -q --show-progress -O guacamole-${NEW_GUAC_VERSION}.war ${GUAC_SOURCE_LINK}/binary/guacamole-${NEW_GUAC_VERSION}.war +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-${NEW_GUAC_VERSION}.war" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-${NEW_GUAC_VERSION}.war${GREY}" + exit 1 +else + rm /etc/guacamole/guacamole.war + mv -f guacamole-${NEW_GUAC_VERSION}.war /etc/guacamole/guacamole.war +fi +echo -e "${LGREEN}Upgraded Guacamole client to version ${NEW_GUAC_VERSION}${GREY}" + +# Download and upgrade Guacamole SQL authentication extension +wget -q --show-progress -O guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz" + exit 1 +else + tar -xzf guacamole-auth-jdbc-${NEW_GUAC_VERSION}.tar.gz + rm /etc/guacamole/extensions/guacamole-auth-jdbc-*.jar + mv -f guacamole-auth-jdbc-${NEW_GUAC_VERSION}/mysql/guacamole-auth-jdbc-mysql-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ +fi +echo -e "${LGREEN}Upgraded Guacamole SQL jdbc to version ${NEW_GUAC_VERSION}${GREY}" + +# Download Guacamole Server +wget -q --show-progress -O guacamole-server-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/source/guacamole-server-${NEW_GUAC_VERSION}.tar.gz +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-server-${NEW_GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/source/guacamole-server-${NEW_GUAC_VERSION}.tar.gz${GREY}" + exit 1 +else + tar -xzf guacamole-server-${NEW_GUAC_VERSION}.tar.gz +fi +echo -e "${LGREEN}Downloaded guacamole-server-${NEW_GUAC_VERSION}.tar.gz${GREY}" + +# Make and install guacd (Guacamole-Server) +cd guacamole-server-${NEW_GUAC_VERSION}/ +echo +echo -e "${GREY}Compiling Guacamole-Server ${NEW_GUAC_VERSION} from source with with GCC $(gcc --version | head -n1 | grep -oP '\)\K.*' | awk '{print $1}'), this might take a few minutes...${GREY}" +# Fix for warnings see #222 https://github.com/MysticRyuujin/guac-install/issues/222 +export CFLAGS="-Wno-error" +# Configure Guacamole Server source +./configure --with-systemd-dir=/etc/systemd/system &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo "Failed to configure guacamole-server" + echo "Trying again with --enable-allow-freerdp-snapshots" + ./configure --with-systemd-dir=/etc/systemd/system --enable-allow-freerdp-snapshots + if [ $? -ne 0 ]; then + echo "Failed to configure guacamole-server - again" + exit + fi +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +echo -e "${GREY}Running Make and building the upgraded Guacamole-Server application..." +make &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +echo -e "${GREY}Installing the upgraded Guacamole-Server..." +make install &>>${LOG_LOCATION} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi +ldconfig + +cd .. + +# Get list of SQL Upgrade Files +echo -e "${GREY}Upgrading MySQL Schema..." +UPGRADEFILES=($(ls -1 guacamole-auth-jdbc-${NEW_GUAC_VERSION}/mysql/schema/upgrade/ | sort -V)) + +# Compare SQL Upgrage Files against old version, apply upgrades as needed +for FILE in ${UPGRADEFILES[@]}; do + FILEVERSION=$(echo ${FILE} | grep -oP 'upgrade-pre-\K[0-9\.]+(?=\.)') + if [[ $(echo -e "${FILEVERSION}\n${OLD_GUAC_VERSION}" | sort -V | head -n1) == ${OLD_GUAC_VERSION} && ${FILEVERSION} != ${OLD_GUAC_VERSION} ]]; then + echo "Patching ${GUAC_DB} with ${FILE}" + mysql -u root -D ${GUAC_DB} -h ${MYSQL_HOST} -P ${MYSQL_PORT} >${LOG_LOCATION} + fi +done +if [ $? -ne 0 ]; then + echo -e "${LRED}SQL upgrade failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Check for DUO extension and upgrade if found +for file in /etc/guacamole/extensions/guacamole-auth-duo*.jar; do + if [[ -f $file ]]; then + echo -e "${LGREEN}DUO authentication extension was found, upgrading...${GREY}" + rm /etc/guacamole/extensions/guacamole-auth-duo*.jar &>>${LOG_LOCATION} + wget -q --show-progress -O guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz" + exit 1 + fi + tar -xzf guacamole-auth-duo-${NEW_GUAC_VERSION}.tar.gz &>>${LOG_LOCATION} + mv -f guacamole-auth-duo-${NEW_GUAC_VERSION}/guacamole-auth-duo-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${LOG_LOCATION} + echo -e "${LGREEN}Upgraded DUO extension to version ${NEW_GUAC_VERSION}${GREY}" + echo + break + fi +done + +# Check for LDAP extension and upgrade if found +for file in /etc/guacamole/extensions/guacamole-auth-ldap*.jar; do + if [[ -f $file ]]; then + echo -e "${LGREEN}LDAP authentication extension was found, upgrading...${GREY}" + rm /etc/guacamole/extensions/guacamole-auth-ldap*.jar &>>${LOG_LOCATION} + wget -q --show-progress -O guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz" + exit 1 + fi + tar -xzf guacamole-auth-ldap-${NEW_GUAC_VERSION}.tar.gz &>>${LOG_LOCATION} + mv -f guacamole-auth-ldap-${NEW_GUAC_VERSION}/guacamole-auth-ldap-${NEW_GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${LOG_LOCATION} + echo -e "${LGREEN}Upgraded LDAP extension to version ${NEW_GUAC_VERSION}${GREY}" + echo + break + fi +done + +# Check for TOTP extension and upgrade if found +for file in /etc/guacamole/extensions/guacamole-auth-totp*.jar; do + if [[ -f $file ]]; then + echo -e "${LGREEN}TOTP authentication extension was found, upgrading...${GREY}" + rm /etc/guacamole/extensions/guacamole-auth-totp*.jar &>>${LOG_LOCATION} + wget -q --show-progress -O guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz ${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz + if [ $? -ne 0 ]; then + echo -e "${LRED}Failed to download guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz" 1>&2 + echo -e "${GUAC_SOURCE_LINK}/binary/guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz" + exit 1 + fi + tar -xzf guacamole-auth-totp-${NEW_GUAC_VERSION}.tar.gz &>>${LOG_LOCATION} + mv -f guacamole-auth-totp-${NEW_GUAC_VERSION}/guacamole-auth-totp-${GUAC_VERSION}.jar /etc/guacamole/extensions/ &>>${LOG_LOCATION} + echo -e "${LGREEN}Upgraded TOTP extension to version ${NEW_GUAC_VERSION}${GREY}" + echo + break + fi +done + +# Fix for #196 see https://github.com/MysticRyuujin/guac-install/issues/196 +mkdir -p /usr/sbin/.config/freerdp +chown daemon:daemon /usr/sbin/.config/freerdp + +# Fix for #197 see https://github.com/MysticRyuujin/guac-install/issues/197 +mkdir -p /var/guacamole +chown daemon:daemon /var/guacamole + +# Bring guacd and Tomcat back up +echo -e "${GREY}Starting guacd and Tomcat services..." +systemctl enable guacd +systemctl start guacd +systemctl start ${TOMCAT_VERSION} +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Cleanup +echo -e "${GREY}Cleanup install files...${GREY}" +rm -rf guacamole-* +unset MYSQL_PWD +if [ $? -ne 0 ]; then + echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 + exit 1 +else + echo -e "${LGREEN}OK${GREY}" + echo +fi + +# Done +printf "${LGREEN}Guacamole ${NEW_GUAC_VERSION} upgrade complete! \n${NC}" +echo -e ${NC} diff --git a/useful-commands.txt b/useful-commands.txt new file mode 100644 index 0000000..8e67cb9 --- /dev/null +++ b/useful-commands.txt @@ -0,0 +1,56 @@ +######################### +Nginx load / DoS testing +######################### +https://ourcodeworld.com/articles/read/949/how-to-perform-a-dos-attack-slow-http-with-slowhttptest-test-your-server-slowloris-protection-in-kali-linux +slowhttptest -c 10000 -H -g -o ./output_file -i 3 -r 500 -t GET -u http://jumpbox.domain.com -x 24 -p 2 + + +############################################### +Audit Guacamole Connections and User access. +############################################### +mysql -u root -p guacamole_db +select + guacamole_entity.name, + guacamole_connection.connection_name, + guacamole_connection_permission.permission +from + guacamole_connection + left join guacamole_connection_permission on guacamole_connection_permission.connection_id = guacamole_connection.connection_id + left join guacamole_entity on guacamole_entity.entity_id = guacamole_connection_permission.entity_id +where + guacamole_connection_permission.permission = 'READ' + and guacamole_entity.name != 'guacadmin'; +Quit to exit + + +############################################### +# Manually reset TOTP configuration for a user +############################################### +#This is likely not needed beyond in Gucamole 1.40 as the gui provides an option to reset. Kept for reference. +mysql -u root -p +use guacamol_db; +SELECT user_id FROM guacamole_user INNER JOIN guacamole_entity ON guacamole_entity.entity_id = guacamole_user.entity_id WHERE guacamole_entity.name = 'guacadmin'; +UPDATE guacamole_user_attribute SET attribute_value='false' WHERE attribute_name = 'guac-totp-key-confirmed' and user_id = '1'; +quit; + + +#################### +Guacamole Debug mode +#################### +sudo systemctl stop guacd && sudo /usr/local/sbin/guacd -L debug -f +Verbose logs will start in the console. + + +############################## +Switch to Debian Testing repo +############################## +sudo apt update && sudo apt upgrade -y # Update first +sudo cp /etc/apt/sources.list sources.list.backup # Backup sources list +sudo sed -i 's/bullseye/testing/g' /etc/apt/sources.list # Switch to testing + +sudo nano /etc/apt/sources.list # Now manually edit + comment out all lines having "security.debian.org" + comment out all lines that end with "updates" + add this line: deb http://security.debian.org testing-security main + +sudo apt update && sudo apt-get install --only-upgrade libssh2-1-dev # update an individual package \ No newline at end of file