diff --git a/1-setup.sh b/1-setup.sh index 511f7c3..e1d9606 100644 --- a/1-setup.sh +++ b/1-setup.sh @@ -17,8 +17,8 @@ # 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. +# 4a-install-self-signed-nginx.sh sets up the new Nginx/Guacamole front end with self signed TLS certificates. +# 4b-install-tls-letsencrypt-nginx.sh sets up Nginx with public TLS 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 @@ -32,6 +32,7 @@ LGREEN='\033[0;92m' LYELLOW='\033[0;93m' NC='\033[0m' #No Colour +# Make sure the user is NOT running this as root if [[ $EUID -eq 0 ]]; then echo echo -e "${LRED}This script must NOT be run as root, exiting..." 1>&2 @@ -39,6 +40,7 @@ if [[ $EUID -eq 0 ]]; then exit 1 fi +# Make sure the user is a member of the sudo group if ! [ $(id -nG "$USER" 2>/dev/null | egrep "sudo" | wc -l) -gt 0 ]; then echo echo -e "${LRED}The current user (${USER}) must be a member of the 'sudo' group, exiting..." 1>&2 @@ -51,11 +53,11 @@ if [ "$(find . -maxdepth 1 \( -name 'guacamole-*' -o -name 'mysql-connector-j-*' # Script branding header echo echo -e "${GREYB}Itiligent VDI & Jump Server Appliance Setup." - echo -e " ${LGREEN}Powered by Guacamole" + 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 -e "${LRED}Possible previous install files detected in current build path. Please review and remove old guacamole install files files before proceeding.${GREY}" 1>&2 echo exit 1 fi @@ -70,7 +72,7 @@ DOWNLOAD_DIR=$USER_HOME_DIR/guac-setup DB_BACKUP_DIR=$USER_HOME_DIR/mysqlbackups/ TMP_DIR=$DOWNLOAD_DIR/tmp -# Github download branch +# GitHub download branch GITHUB="https://raw.githubusercontent.com/itiligent/Guacamole-Install/main/" #Version of Guacamole to install @@ -84,6 +86,7 @@ MYSQLJCON="8.0.33" # Select a specific MySQL version. See https://mariadb.org/mariadb/all-releases/ MYSQL_VERSION="" # If left blank, script will use Linux distro default version packages. +# Setup MySQL package name variables to call based on the above MYSQL_VERSION option if [ -z "${MYSQL_VERSION}" ]; then # Use Linux distro default version. MYSQLSRV="default-mysql-server default-mysql-client mysql-common" @@ -115,7 +118,7 @@ LOG_LOCATION="${DOWNLOAD_DIR}/guacamole_${GUAC_VERSION}_setup.log" 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. +# to other distros easier. Here the variables for the library dependency names are initialised. source /etc/os-release OS_FLAVOUR=$ID OS_VERSION=$VERSION @@ -172,15 +175,15 @@ INSTALL_DUO="" # Add DUO MFA extension (can't be installed simu INSTALL_LDAP="" # Add Active Directory extension (true/false) CHANGE_ROOT="" # Set default Guacamole URL to http root (remove extra "/guacamole" from the default URL) 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/or self signed ssl certificates -SELF_SIGN="" # Add self signed SSL support to Nginx (Let's Encrypt not available with this, true/false) +PROXY_SITE="" # Local DNS name for reverse proxy and/or self signed TLS certificates +SELF_SIGN="" # Add self signed TLS support to Nginx (Let's Encrypt not available with this option, true/false) CERT_COUNTRY="AU" # Self signed cert setup: 2 country character code only, must not be blank CERT_STATE="Victoria" # Self signed cert setup: Optional to change, must not be blank CERT_LOCATION="Melbourne" # Self signed cert setup: Optional to change, must not be blank CERT_ORG="Itiligent" # Self signed cert setup: Optional to change, must not be blank CERT_OU="I.T." # Self signed cert setup: Optional to change, must not be blank CERT_DAYS="3650" # Self signed cert setup: 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 option, true/false) +LETS_ENCRYPT="" # Add Lets Encrypt public TLS support for Nginx (self signed TLS certs not available with this option, true/false) LE_DNS_NAME="" # Public DNS name to bind with Lets Encrypt certificates LE_EMAIL="" # Webmaster/admin email for Lets Encrypt notifications BACKUP_EMAIL="" # Email address for backup notifications @@ -192,7 +195,7 @@ RDP_PRINTER_LABEL="RDP Printer" # Custom Windows RDP printer name # Script branding header echo echo -e "${GREYB}Itiligent VDI & Jump Server Appliance Setup." -echo -e " ${LGREEN}Powered by Guacamole" +echo -e " ${LGREEN}Powered by Guacamole" echo echo @@ -210,8 +213,8 @@ 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 +wget -q --show-progress ${GITHUB}4a-install-tls-self-signed-nginx.sh -O 4a-install-tls-self-signed-nginx.sh +wget -q --show-progress ${GITHUB}4b-install-tls-letsencrypt-nginx.sh -O 4b-install-tls-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 @@ -220,7 +223,7 @@ wget -q --show-progress ${GITHUB}add-smtp-relay-o365.sh -O add-smtp-relay-o365.s 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-tls-guac-daemon.sh -O add-tls-guac-daemon.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 @@ -231,7 +234,7 @@ clear # Script branding header echo echo -e "${GREYB}Itiligent VDI & Jump Server Appliance Setup." -echo -e " ${LGREEN}Powered by Guacamole" +echo -e " ${LGREEN}Powered by Guacamole" echo echo @@ -249,7 +252,7 @@ sudo chown -R $SUDO_USER:root $TMP_DIR # 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. +# hostnames and matching DNS entries are essential for implementing TLS 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 @@ -269,7 +272,7 @@ else sudo systemctl restart systemd-hostnamed &>>${LOG_LOCATION} fi -# We need a dns suffix to append to the hostname so as SSL can be available. +# We need a dns suffix to append to the hostname so as TLS can be available. 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 @@ -310,7 +313,7 @@ clear # Script branding header echo echo -e "${GREYB}Itiligent VDI & Jump Server Appliance Setup." -echo -e " ${LGREEN}Powered by Guacamole" +echo -e " ${LGREEN}Powered by Guacamole" echo echo @@ -504,10 +507,10 @@ if [ -z "${PROXY_SITE}" ]; then PROXY_SITE="${DEFAULT_FQDN}" fi -# Prompt for self signed SSL reverse proxy option +# Prompt for self signed TLS 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 "FRONT END: Add self signed SSL support to Nginx? [y/N]? (choose 'n' for Let's Encrypt)[default n]: " + # Prompt the user to see if they would like to install self signed TLS support for Nginx, default of no + echo -e -n "FRONT END: Add self signed TLS support to Nginx? [y/N]? (choose 'n' for Let's Encrypt)[default n]: " read PROMPT if [[ ${PROMPT} =~ ^[Yy]$ ]]; then SELF_SIGN=true @@ -516,19 +519,19 @@ if [[ -z ${SELF_SIGN} ]] && [[ "${INSTALL_NGINX}" = true ]]; then fi fi -# Optional prompt to assign the self sign SSL certificate a custom expiry date, un-comment to force a manual entry +# Optional prompt to assign the self sign TLS 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 +# read - p "PROXY: Enter number of days till TLS 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 no self sign TLS 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 +# Prompt for Let's Encrypt TLS reverse proxy configuration option if [[ -z ${LETS_ENCRYPT} ]] && [[ "${INSTALL_NGINX}" = true ]] && [[ "${SELF_SIGN}" = "false" ]]; then - echo -e -n "FRONT END: Add Let's Encrypt SSL support to Nginx reverse proxy [y/N] [default n]: ${GREY}" + echo -e -n "FRONT END: Add Let's Encrypt TLS support to Nginx reverse proxy [y/N] [default n]: ${GREY}" read PROMPT if [[ ${PROMPT} =~ ^[Yy]$ ]]; then LETS_ENCRYPT=true @@ -565,7 +568,7 @@ fi clear echo echo -e "${GREYB}Itiligent VDI & Jump Server Appliance Setup." -echo -e " ${LGREEN}Powered by Guacamole" +echo -e " ${LGREEN}Powered by Guacamole" echo echo echo -e "${LGREEN}Beginning Guacamole setup...${GREY}" @@ -599,11 +602,11 @@ 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 +sed -i "s|CERT_COUNTRY=|CERT_COUNTRY='${CERT_COUNTRY}'|g" $DOWNLOAD_DIR/add-tls-guac-daemon.sh +sed -i "s|CERT_STATE=|CERT_STATE='${CERT_STATE}'|g" $DOWNLOAD_DIR/add-tls-guac-daemon.sh +sed -i "s|CERT_LOCATION=|CERT_LOCATION='${CERT_LOCATION=}'|g" $DOWNLOAD_DIR/add-tls-guac-daemon.sh +sed -i "s|CERT_ORG=|CERT_ORG='${CERT_ORG}'|g" $DOWNLOAD_DIR/add-tls-guac-daemon.sh +sed -i "s|CERT_OU=|CERT_OU='${CERT_OU}'|g" $DOWNLOAD_DIR/add-tls-guac-daemon.sh # Export the relevant variable selections to child install scripts export BACKUP_EMAIL=$BACKUP_EMAIL @@ -675,16 +678,16 @@ if [ "${INSTALL_NGINX}" = true ]; then echo -e "${LGREEN}Nginx install complete\nhttp://${PROXY_SITE} - admin login: guacadmin pass: guacadmin\n${LYELLOW}***Be sure to change the password***${GREY}" fi -# Apply self signed SSL certificates to Nginx reverse proxy if option is selected +# Apply self signed TLS 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} + sudo -E ./4a-install-tls-self-signed-nginx.sh ${PROXY_SITE} ${CERT_DAYS} echo -e "${LGREEN}Self signed certificate configured for Nginx \n${LYELLOW}https:${LGREEN}//${PROXY_SITE} - admin login: guacadmin pass: 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 +# Apply Let's Encrypt TLS 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} - admin login: guacadmin pass: guacadmin\n${LYELLOW}***Be sure to change the password***${GREY}" + sudo -E ./4b-install-tls-letsencrypt-nginx.sh + echo -e "${LGREEN}Let's Encrypt TLS configured for Nginx \n${LYELLOW}https:${LGREEN}//${LE_DNS_NAME} - admin login: guacadmin pass: 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 diff --git a/2-install-guacamole.sh b/2-install-guacamole.sh index fc0d393..c68b57e 100644 --- a/2-install-guacamole.sh +++ b/2-install-guacamole.sh @@ -4,8 +4,6 @@ # 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 diff --git a/3-install-nginx.sh b/3-install-nginx.sh index 5805aa5..09ee68d 100644 --- a/3-install-nginx.sh +++ b/3-install-nginx.sh @@ -1,6 +1,6 @@ #!/bin/bash ####################################################################################################################### -# Add Nginx reverse proxy fromt end to default Guacamole install +# Add Nginx reverse proxy front end to default Guacamole install # For Ubuntu / Debian / Raspbian # 3 of 4 # David Harrop @@ -55,8 +55,6 @@ fi sudo sed -i -e '/ssl_protocols/s/^/#/' /etc/nginx/nginx.conf sudo sed -i "/SSL Settings/a \ ssl_protocols TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE" /etc/nginx/nginx.conf - - # Symlink from sites-available to sites-enabled ln -s /etc/nginx/sites-available/$PROXY_SITE /etc/nginx/sites-enabled/ diff --git a/4a-install-ssl-self-signed-nginx.sh b/4a-install-tls-self-signed-nginx.sh similarity index 75% rename from 4a-install-ssl-self-signed-nginx.sh rename to 4a-install-tls-self-signed-nginx.sh index ff47212..734fa81 100644 --- a/4a-install-ssl-self-signed-nginx.sh +++ b/4a-install-tls-self-signed-nginx.sh @@ -1,6 +1,6 @@ #!/bin/bash ####################################################################################################################### -# Add self signed SSL certificates to Guacamole with Nginx reverse proxy +# Add self signed TLS certificates to Guacamole with Nginx reverse proxy # For Ubuntu / Debian / Rasbpian # 4a of 4 # David Harrop @@ -18,41 +18,15 @@ NC='\033[0m' #No Colour echo echo -echo -e "${LGREEN}Setting up self signed SSL certificates for Nginx...${GREY}" +echo -e "${LGREEN}Setting up self signed TLS 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..." +echo -e "${GREY}Discovering the default route interface and Proxy DNS name to bind with the new TLS 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 @@ -62,8 +36,8 @@ else echo fi -echo -e "${GREY}New self signed SSL certificate attributes are shown below...${DGREY}" -# Display the new SSL cert parameters. +echo -e "${GREY}New self signed TLS certificate attributes are shown below...${DGREY}" +# Display the new TLS cert parameters. cat <&2 @@ -123,7 +91,7 @@ else echo fi -# Place SSL Certificate within defined path +# Place TLS Certificate within defined path sudo cp $SSLNAME.key $DIR_SSL_KEY/$SSLNAME.key sudo cp $SSLNAME.crt $DIR_SSL_CERT/$SSLNAME.crt @@ -151,7 +119,7 @@ else 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}" +echo -e "${GREY}Configuring Nginx proxy to use self signed TLS 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}" -#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} @@ -83,7 +38,7 @@ else 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}" +echo -e "${GREY}Configuring Nginx proxy for Let's Encrypt TLS and setting up automatic HTTP redirect...${GREY}" cat >/etc/nginx/sites-available/$PROXY_SITE <&2 diff --git a/add-auth-totp.sh b/add-auth-totp.sh index fd4025f..fe7912d 100644 --- a/add-auth-totp.sh +++ b/add-auth-totp.sh @@ -17,6 +17,7 @@ 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 diff --git a/add-fail2ban.sh b/add-fail2ban.sh index 889fc84..1745ad7 100644 --- a/add-fail2ban.sh +++ b/add-fail2ban.sh @@ -17,6 +17,7 @@ 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 @@ -40,10 +41,10 @@ rm -f /tmp/fail2ban.update # Start setup prompts ################################################################################################# ####################################################################################################################### -# Prompt to install fail2ban base app, default of yes +# Prompt to install fail2ban base package with no policy as yet, default of yes if [[ -z ${FAIL2BAN_BASE} ]]; then echo - echo -e -n "${LGREEN}Install Fail2ban? [default y]: ${GREY}" + echo -e -n "${LGREEN}Install Fail2ban? (base package with no policy as yet) [default y]: ${GREY}" read PROMPT if [[ ${PROMPT} =~ ^[Nn]$ ]]; then FAIL2BAN_BASE=false @@ -63,40 +64,40 @@ if [[ -z ${FAIL2BAN_GUAC} ]] && [[ "${FAIL2BAN_BASE}" = true ]]; then 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 Nginx fail2ban config defaults , default of no - NOT IMPLEMENTED YET +#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 +# Prompt to install SSH fail2ban config defaults , default of no - NOT IMPLEMENTED YET +#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) +# Install base fail2ban base application, and whitelist the local subnet as the starting baseline (no policy defined yet) if [ "${FAIL2BAN_BASE}" = true ]; then - #Update and install fail2ban (and john for management of config file updates) + #Update and install fail2ban (and john for management of config file updates, and not overwrite any existing settings) 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 + # Create the basic jail.local template and local subnet whitelist cat >/tmp/fail2ban.conf < /etc/fail2ban/jail.local' # Clean up @@ -190,7 +191,7 @@ if [ "${FAIL2BAN_BASE}" = true ]; then rm -f /tmp/netaddr.txt rm -f /tmp/fail2ban.update - # bounce the service to relaod the new config + # bounce the service to reload the new config sudo systemctl restart fail2ban # Done @@ -204,16 +205,18 @@ else fi ####################################################################################################################### -# Fail2ban optional setup items ####################################################################################### +# Fail2ban optional policy setup items ################################################################################ ####################################################################################################################### +if [ "${FAIL2BAN_GUAC}" = true ]; then + # Create the Guacamole jail.local policy template cat >/tmp/fail2ban.conf <&2 diff --git a/add-ssl-guac-gaucd.sh b/add-tls-guac-daemon.sh similarity index 86% rename from add-ssl-guac-gaucd.sh rename to add-tls-guac-daemon.sh index f9311e2..0ff2795 100644 --- a/add-ssl-guac-gaucd.sh +++ b/add-tls-guac-daemon.sh @@ -1,6 +1,6 @@ #!/bin/bash ####################################################################################################################### -# Harden Guacd <-> Guac client traffic in SSL wrapper +# Harden Guacd <-> Guac client traffic in TLS wrapper # For Ubuntu / Debian / Raspbian # David Harrop # April 2023 @@ -15,6 +15,7 @@ LGREEN='\033[0;92m' LYELLOW='\033[0;93m' NC='\033[0m' #No Colour +# Below variables are automatically updated by the 1-setup.sh script with the respective values given at install CERT_COUNTRY= CERT_STATE= CERT_LOCATION= @@ -23,13 +24,14 @@ CERT_OU= 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 -# Create the special directory for guacd ssl certfifacte and key. +# Create the special directory for guacd tls certificate and key. sudo mkdir /etc/guacamole/ssl echo cat <&2